Currently I am processing a XML data (in MBs) as follows,
- Create DOM object for XML record.
- Apply XPath queries on DOM object to retrieve fields.
My XML is as follows,
<root>
<element>
<sub-element>A</sub-element>
<sub-element>B</sub-element>
</sub-element>
<sub-element>D</sub-element>
<sub-element>E</sub-element>
</element>
</root>
Scenario #1: retrieve list of sub-elements of an element is expected to return the following output
sub-element - {'A','B','','D','E'} - 3rd node in XML contains empty/null, which should be created as empty node. But currently I am getting output as {'A','B','D','E'} 3rd value is not created.
Scenario #2: there are some complex queries being used in our application which is tedious in XPATH to retrieve a field from XML DOM object (like parameterized XPATHs)
Is there any way that we could achieve this using DOM itself in efficient and fastest way?
or
Do we need to create a object graph from XML (through XStream) and process the query through normal java way of proccessing the POJO object?
or
Any best way of doing this?
Thanks in advance.