I process many, many XML files containing HL7 Info.
The structure of these XML files is described in several complex XSD files. They are a hierarchy of XSD files. eg:
- Messages.xsd
- batch.xsd
- datatypes.xsd
- MoreFiles.xsd
This is not an exact use, but it helps to understand how they work.
Now i can run
xsd. \ messages.xsd / classes
and he creates a file called messages.cs whose length exceeds 240,000 lines.
Note. Despite the complexity of XSD, actual xml files average about 250 XML lines with about 25 characters per line (not very large).
I can use this file to deserialize my xml files as follows:
var bytes = Encoding.ASCII.GetBytes(message.Message); var memoryStream = new MemoryStream(bytes); var message = ormSerializer.Deserialize(memoryStream);
Everything works fine and fast.
When it comes time to pull data from the xml structure, it is too slow .
Is there any other way to access my xml data which will be faster? Should I use XPathDocument
and XPathNavigator
? Can XPathNavigator
use all XSD files, so I don’t need to recreate it for every xml file being processed (not all XML nodes are in all XML files)?
Any other ideas for getting XML data quickly?
source share