Working with XML Elements

Often it is necessary to do more than simply read and/or display XML data; often you want to add data to an XML document. The XmlElement class is used to create new elements that can be appended to an existing XmlDocument object. Much like creating new DataRows in a DataTable, XmlElements are created by setting an instance of the XmlElement class to the result of calling XmlDocument.CreateElement([element name]). For example, it would be very useful to add new users to the users.xml document in the previous examples. Effectively, you could create a Web Form for adding new users to your application by accepting the user information in a form and creating a new <User> element in the users.xml document.

Creating an instance ...

Get Programming Data-Driven Web Applications with ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.