Recently I wrote about differing mechanisms for reading and displaying data stored in XML files. Many applications would not be complete without some form of editing. Most would probably use a straight text editor such as Notepad or vi, but sometimes editing XML can be a daunting task. In this article, we delve into the editing capabilities of .NET's XML classes.
Requirements for running the example code are:
.NET Beta 2 SDK
Windows 2000 and IIS 5.0
A basic understanding of .NET (namespace compiles and deployment).
Your favorite text editor. Visual Studio.NET will not be covered.
Much of the same knowledge from the previous article will apply to the forthcoming exercises. Open up the .NET reference materials, and let's get started.
Same Old Data
Once again we will stick with the original data format to continue the theme of building a Web-based contacts application. As a refresher, here is an example of the data used in the previous article:
<personal_information> <contacts> <entry id="0" initials="jxd" keywords="friend, bar" /> <name first="John" middle="X" last="Doe" gender="m" /> <phone type="home" acode="555" number="555-1212" /> <phone type="work" acode="555" number="555-6969" /> <address type="home"> <line seq="1">123 Main Street</line> <line seq="2">#456</line> <city>Manhattan</city> <state>New York</state> <zipcode>10011</zipcode> </address> </entry> </contacts> </personal_information>
For this article, our focus will be on editing specifically the <entry /> and <name /> nodes, for the sake of simplicity. However, the same concepts will be applicable to the other nodes in this data or any XML file that you'd like to edit with a .NETbased Web interface.