Friday, December 20, 2013

Java : XPathReader with CDATA

String xpath = "//IDOC[position()>=1 and position()<=3]";
XPath xpathObj = XPath.getXPathInstance(xpath);
XPathReader xpathReaderObj = XPathReader.getXPathReader(xpathObj, null,oDoc, fileName);;
int resultNode = xpathReaderObj.loadNextNode();

Explanation of the above scenario :
In Order to read the data only chunkwise you need to go with xpathReader to have better performance as this thing will be reading on chunk basis.

Problem : But the problem with this function is, It won't load the CDATA elements if your XML have any. Instead the element nodes will be empty.

No comments:

Post a Comment