codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:



 


Previous Page  Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 Page 9 Page 10 Page 11  Page 13 Next Page  

The Role of XML in ASP.NET

As with virtually every other aspect of the .NET Framework, XML plays a very large part, in terms of data transmission and configuration. The web.config and other such configuration-specific files are written entirely in XML, and are evaluated against schemas resident in the framework itself. In order to program against this framework and to properly configure and secure your web applications, XML will become of paramount importance.

 

Of course, the web services movement is one of the driving forces in the development of .NET. As a result, SOAP, WSDL, and XML all play a key role in data transmission between .NET applications. Using SOAP as a method of object interchange between two or more .NET applications, it's even possible to deliver XML schema representations of any serializable class of the framework via SOAP and WSDL. Imagine viewing an XML representation of a System.Data.DataSet object, or some other complex framework class? It's all possible, due to the fact that .NET's underpinnings are XML, SOAP, and the HTTP pipeline.


Additionally, it's important to note that at the very lowest levels of some of the objects and classes found within the framework, XML is used as a low-level building block. Many objects, such as the System.Data.DataSet and System.Data.DataRelation classes, have methods specialized for the very purpose of XML generation. Consider the notion of a hierarchical data structure generated using a TSQL SHAPE statement that you need to get into XML format. You'd be required to write a huge recursive function that would iterate through the recordset and all of its child columns and recordsets.

 

In COM, this would take hours using script, possibly a component or two, and complex recursion tactics that are nearly impossible to debug. .NET provides us with some nice objects and built-in XML generation support to do just that. Take a look at our data retrieval and relationship-generation code:

 

SqlConnection conn = new SqlConnection("Server=US20207014;UID=sa;PWD=pass4sql;Initial Catalog=pubs");

DataSet dataset = new DataSet();

SqlCommand cmd = new SqlCommand();

SqlDataAdapter sda = new SqlDataAdapter();

DataColumn colTitles;

DataColumn colPubs;

conn.Open();

cmd.Connection = conn;

dataset.Tables.Add("Titles");

dataset.Tables.Add("Publishers");

cmd.CommandText = "SELECT title, type, pub_id FROM titles";

sda.SelectCommand = cmd;

sda.Fill(dataset,"Titles");

cmd.CommandText = "SELECT pub_name,pub_id FROM Publishers";

sda.SelectCommand = cmd;

sda.Fill(dataset,"Publishers");

colTitles = dataset.Tables["Titles"].Columns["pub_id"];

colPubs = dataset.Tables["Publishers"].Columns["pub_id"];

DataRelation rel = new DataRelation("TitlesPublishers", colPubs, colTitles);

dataset.Relations.Add(rel);

 

// this line is the magical one that creates the "tree"

rel.Nested = true;

StringWriter sw = new StringWriter();

dataset.WriteXml(sw);

 

Possibly the most important line in this fragment is the line that reads

 

rel.Nested = True

 

This property tells the application to "nest" the XML results that are generated from the dataset. Without this line, we'll still get XML, but without the elegant nesting behavior shown below:

 

<Publishers>

    <pub_name>Algodata Infosystems</pub_name>

    <pub_id>1389</pub_id>

    <Titles>

      <title>The Busy Executive's Database Guide</title>

      <type>business    </type>

      <pub_id>1389</pub_id>


    </Titles>

    <Titles>

      <title>Cooking with Computers: Surreptitious Balance Sheets</title>

      <type>business    </type>

      <pub_id>1389</pub_id>

    </Titles>

    <Titles>

      <title>Straight Talk About Computers</title>

      <type>business    </type>

      <pub_id>1389</pub_id>

    </Titles>

    <Titles>

      <title>But Is It User Friendly?</title>

      <type>popular_comp</type>

      <pub_id>1389</pub_id>

    </Titles>

    <Titles>

      <title>Secrets of Silicon Valley</title>

      <type>popular_comp</type>

      <pub_id>1389</pub_id>

    </Titles>

    <Titles>

      <title>Net Etiquette</title>

      <type>popular_comp</type>

      <pub_id>1389</pub_id>

    </Titles>

  </Publishers>

  <Publishers>

    <pub_name>Five Lakes Publishing</pub_name>

    <pub_id>1622</pub_id>

  </Publishers>

 

Try doing that in COM using ADO and MSXML! You could, obviously, but it would take hours to code, days to debug, and still wouldn't perform as well.

Previous Page  Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 Page 9 Page 10 Page 11  Page 13 Next Page  




Click here to Buy!

Buy Fast Track ASP.NET here

© Copyright 2002 Wrox Press These chapter is written by Brady Gaster, Marco Bellinaso & Kevin Hoffman and taken from "Fast Track ASP.NET" published by Wrox Press Limited in June 2002; ISBN 1861007191; copyright © Wrox Press Limited 2002; all rights reserved.

No part of these chapters may be reproduced, stored in a retrieval system or transmitted in any form or by any means -- electronic, electrostatic, mechanical, photocopying, recording or otherwise -- without the prior written permission of the publisher, except in the case of brief quotations embodied in critical articles or reviews.











Recent Forum Threads
• mkdirs
• Re: Web Development Project
• ** Site Hacked ** javascript inserted...
• Losing background/text color when converting HTML to PDF
• hidden div block when displayed, displays at an offset of 200px only in IE 6..
• help - sketch
• Re: Perl Script - File Handling.
• Open a file from website
• Re: to open 5 terminals from one and also execute different commands on each terminal


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008