O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing XML Elements

Now that the XML declaration is written, it's time to start writing some real XML data. The most important node is the XML element. Elements can be written piece by piece or all at once.

Writing an element piece by piece is necessary when the element needs to contain attributes or child nodes. The XmlTextReader provides WriteStartElement and WriteEndElement to support this functionality. Calling WriteStartElement will write the specified start tag and associate it with an optional namespace and prefix. After the start tag is written, you can then write attributes on the element. You can also write child nodes. But you can no longer write an attribute on an element after a child node has been written.

Listing 10.23 demonstrates ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required