Background
We have a project that was launched in .NET 1.1, ported to .NET 2.0, and recently migrated to .NET 3.5. The project is extremely data driven and uses XML for many of its data files. Some of these XML files are quite large, and I would like to take the opportunity that I currently need to improve to interact with them. If possible, I want to avoid the need to keep them completely in memory at any time, but on the other hand, I want to quickly access their data.
The current setting uses XmlDocumentand XPathDocument(depending on when it was written and by whom). Data is viewed on first request and caching in the internal data structure (and not as XML, which in most scenarios takes up more memory). It used to be a good model, because it had fast access times and low memory (or at least a satisfactory memory size). Now, however, there is a function that requests most of the information at a time, rather than the well-sent requests that we previously had. This causes XML loading, validation, and parsing to be a noticeable performance bottleneck.
Question
Given a large XML file, what is the most efficient and responsive way to request its contents (for example, "does an element A with id = B exist?") Several times without XML in memory?
Please note that the data itself may be in memory, and not in a more bloated form of XML, if we can help. In the worst case scenario, we could accept a single file loaded into memory, which will be parsed and then uploaded again to free resources, but I would like to avoid this, if at all possible.
Given that we already caching the data, where we can, this question can also be read as "which is faster and uses less memory: XmlDocument, , syntactic analysis on the basis of , or / the LINQ-to -xml ?" XPathDocumentXmlReader XDocument
: , XML ?
XML :
<MyXml>
<Record id='1'/>
<Record id='2'/>
<Record id='3'/>
</MyXml>
, 3. , , . , XML, , .
, XML, , XML .
, MSDN, Google , - , , , , .
XMLTeam , XML-API .NET. , -, XmlReader IEnumerable, , .