Library tutorials & articles
Reading, Storing and Transforming XML Data in .NET
Introduction
Unless you happened to be involved in some other career field, it would almost impossible to not realize that XML is steadily growing as a common data exchange format that can used be across any platform. As long as you conform to standard XML specifications, you can send your XML file anywhere, have it parsed or searched, and displayed as if it were perhaps on your local computer.
With .NET's arrival, reading data from a database, writing your results to an XML file, transforming it with an XSL stylesheet or even binding Web controls has become almost effortless, when compared to classic ASP. .NET offers developers many options with which they can manipulate and present data.
This article will illustrate a mixture of common .NET methods for formatting and presenting in a readable fashion any XML document you may encounter. The latest hype with XML Web services and even the .NET Framework itself relies on XML as its backbone, therefore this is no light matter. Furthermore, .NET offers numerous ways and XML objects for reading, writing and querying your XML. They primarily fall into three sections - Reading, Writing and Transforming XML, Storing and Manipulating your XML, and lastly Querying XML documents. In this article I'll demonstrate two of those. I'll use Net's more commonly used XML Document Object Model as part of the W3C DOM.
In this article, we will look at a few things:
- How to connect to a database and query it
- Writing or storing our search results to a local XML file
- Utilize the File System Object for some conditional testing
- Read our XML file from our local drive, transform and present it via XSL into our XML Web Control
- Lastly, we'll also use our performed XML document as a datasource and demonstrate the ease of binding a Datagrid Control with it
Related articles
Related discussion
-
handling special character in xslt's
by bussureddy82 (1 replies)
-
Reading an RSS file in ASP .NET
by TimL (31 replies)
-
Create a Site Search Engine in ASP.NET
by Soundguy53 (64 replies)
-
Cross page postbacks in ASP.NET 2.0
by PhilWhite (9 replies)
-
virtual directory asp.net
by yogeshkadvekar (3 replies)
Related podcasts
-
Writing FaceBook Applications with .NET - Interview with Mel Sampat, author of Outsync
In this episode, Scott talks with Mel Sampat, a Program Manager at Microsoft who's written OutSync, an application that syncs faces between Outlook, Facebook, and indirectly Windows SmartPhones. They chat about what it takes to write your own FaceBook application using ASP.NET or WinForms.
Events coming up
-
Mar
15
DevWeek 2010
London, United Kingdom
DevWeek is Europe’s leading independent conference for software developers, database professionals and IT architects, and features expert speakers on a wide range of topics, including .NET 4.0, Silverlight 3, WCF 4, Visual Studio 2010, REST, Windows Workflow 4, Thread Synchronization, ASP.NET 4.0, SQL Server 2008 R2, LINQ, Unit Testing, CLR & C# 4.0, .NET Patterns, WPF 4, F#, Windows Azure, ADO.NET, Entity Framework, Debugging, T-SQL Tips & Tricks, and more.
Hey Kurt,
The xsl file is the xml transformation file which parses the xml into more readable html.
i might be very slow here, but what part of the code here are supposed to be used in the pubs.xsl file? yes, I am a newbie :-)
Regards,
Kurt
Norway
Thanks - I'll check that and edit the article to fix it
Very good example, simple but contains a lot of information. Only one part I had to modify, in the XSL I had to change the criteria for the select from "PubsList/Pubs" to "PubsList/Table" as the child node is table and not pubs. I also had to grant write access to ASPNET account for the folder where I'm creating the XML.
Thanks,
Reem
This thread is for discussions of Reading, Storing and Transforming XML Data in .NET.