NET - Explain how to read the contents of an XML document using XMLTextReader

Explain how to read the contents of an XML document using XMLTextReader.

- There are two methods for reading XML that is XmlDocument class and the XmlReader class.

- Both the XmlReader and XmlDocument classes can read XML from a remote URL just as well as from a local file.

1.XmlDocument:

- It reads the entire XML document into memory and then lets you navigate back and forward to it as you please or even query the document using the XPath technology.

2.XmlReader:

- It is faster and less memory-consuming alternative.
- XmlReader lets you run through the XML document one element at a time, while allowing you to look at the value and then moves to the next element.
- It consumes very little memory because it holds the current element.
- You will only get the relevant elements because you manually checking the values.

Example:
XmlTextReader xmlReader = new XmlTextReader(@"c:\abc.xml");
while(xmlReader.Read())
{
   Console.Writeln(xmlReader.Value);
}
NET - Explain how to write data to an XML file
Answer - Explain how to write data to an XML file.......
NET - Explain how XPathNavigator read data from an XMLDocument
Answer - Explain how XPathNavigator read data from an XMLDocument.......
NET - What is an XML Web service?
What is an XML Web service? - XML Web Service is a unit of code that can be accessed independent of platforms and systems.......
Post your comment