O'Reilly logo

Applied XML Programming for Microsoft® .NET by Dino Esposito

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

The XML Writer Programming Interface

An XML writer represents a component that provides a fast, forward-only way of outputting XML data to streams or files. More important, an XML writer guarantees—by design—that all the XML data it produces conforms to the W3C XML 1.0 and Namespace recommendations.

Suppose you have to render in XML the contents of a string array. The following code normally fits the bill:

 void CreateXmlFile(String[] theArray, string filename) {     StringBuilder sb = new StringBuilder("");     // Loop through the array and build the file     sb.Append("<array>");     foreach(string s in theArray)     {         sb.Append("<element value=\"");         sb.Append(s);         sb.Append("\"/>");     }     sb.Append("</array>"); ...

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