Monday, March 12, 2012

why to use xmldocument and xmltextReader together?

Hello I saw an example at: http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx

XmlDocument doc =new XmlDocument();
//Load the the document with the last book node.
XmlTextReader reader =new XmlTextReader("c:\\books.xml");
reader.Read();
// load reader
doc.Load(reader);

I just don't get it why do we need to use theXMLDocument and XmlTextReader togetherlike that. I thought the main purpose of using XMLTextReader is that it is more efficient then XMLDocument.

Kindly advice.

Its a tossup? The XMLDocument is more flexable then the XMLTextReader, but the XMLTextReader is much faster when its coming to reading.

Checkout this blog that I found. Good Reading:

http://ryangregg.com/PermaLink,guid,8464b4b2-b07f-41fa-972f-c8d535027875.aspx


everybody provides a difference between XMLdocument and xmltextreader, and I understand that we should try to use xmltextreader where ever possible.

but what about xpathdocument, where does this fall as compared to xmldocument and xmltextreader.

thanks

0 comments:

Post a Comment