Creating XML Trees with the XmlTextWriter and XmlDocument Objects
(Page 1 of 7 )
So you know all about reading and parsing XML files, and even checking if they're well-formed and valid. Now, take a step into more advanced territory with this expose of two objects that let you dynamically create well-formed XML documents in your ASP.NET scripts.
Reading And Writing
If you've been following past issues of this column, you're probably already aware of the numerous things you can do with XML and the .NET framework. You already know that there are two ways XML can be parsed, either via the Document Object Model (DOM) or the Microsoft-inspired "pull" model; that each method has pros and cons; that the selection of a parsing technique depends largely on the application; and that the .NET framework today supports both parsing methods, making it a versatile and flexible tool for XML application development.
Now, reading XML data is only half of the puzzle. Take a minute to think about the developer who gets an XML feed from a third-party vendor and needs to rejigger this data into a new XML file based on a custom DTD or XML Schema. How does (s)he do this? Is it possible to write an XML file on-the-fly?
Well, guess what? Just as there are two classes for reading XML data, the .NET framework comes with two for writing XML as well. The first of these is the handy XmlTextWriter object, which lets you write XML at run-time, and the second is the XmlDocument object, which allows you create XML files on-the-fly.
Intrigued? Keep reading.
Next: Spending Time in the Library >>
More XML Articles
More By Harish Kamath (c) Melonfire