|
|
Working with XML Reader and WriterThe System.Xml namespace provides the XmlReader and XmlWriter classes that enable you to parse and write XML data from streams or XML documents. XMLReaderThe XmlReader class allows you to access XML data from a XML document. The XmlTextReader class is used when you require fast access to XML data. Below is the code to read data from an XML document using XmlTextReader object. Visual Basic .NET Dim reader As New XmlTextReader("c:\mysecond.xml") Visual C#.Net XmlTextReader readxml = new XmlTextReader("myfirst.xml"); XMLWriterThe XmlWriter class is an abstract class that enables you to write data to well-formed XML documents. The XmlTextWriter class, which is a derived class of XmlWriter, provides properties and methods that you use to write XML data to a file, stream, console, or other types of output. Visual Basic .NET Dim xmlwrite As New XmlTextWriter("c:\mysecond.xml", System.Text.Encoding.UTF8) xmlwrite.WriteStartElement("Employees") Visual C#.Net XmlTextWriter writexml =new XmlTextWriter("c:\mysecond.xml", xmlwrite.WriteStartElement("Employees"); |

