I am trying to find out if there is a way to calculate the file size from XmlReader. I don't see anything on the reader object that helps determine the size. Any ideas? Thank you!
Using reader As Xml.XmlReader = GetXML(columnName.ToString())
End Using
Based on my understanding of the two classes, XmlReader should perform faster in my scenario because it reads through an XML document only once, never storing more than the current node in memory. On the contrary, XmlDocument stores the whole XML file in memory which has some performance overhead.
There is no limit of XML file size but it takes memory (RAM) as file size of XML file, so long XML file parsing size is performance hit. It is advised to long XML size using SAX for . NET to parse long XML documents.
XDocument is from the LINQ to XML API, and XmlDocument is the standard DOM-style API for XML. If you know DOM well, and don't want to learn LINQ to XML, go with XmlDocument .
XmlReader
might not read from something that has a known or definite size. Your best bet would be to do something with the source of whatever the XmlReader
is reading. E.g. you might have a Stream
and try to get Stream.Length
(some streams don't support this, as they don't have a length). This will require modifying GetXML
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With