Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML XPath with Stream

Status
Not open for further replies.

funxav

Programmer
Jun 13, 2003
15
FR
Hello.

I'm searching an API, which permit to do XPath selection. But all I have seen permit XPath selection in documents (so in memory).

But my files will be to big to be loaded in memory. And I'd like an XPath selection API which operates on stream.(Input Stream or other possible XML Stream).

I have searched into a lot of XML API but I havn't found...

Does anyone know what I am looking for ?
 
Thanks for answer.
What I'm looking for can be for example this method :
evaluate(String expr, InputSource source, QName retType)

that is in jdk1.5.0,but I have 1.4

I have readen

It seems to be that all the XPath slection methods takes necessarily a Document object in which to search.
And Document object implies that all XML data have been loaded into memory. Isn't it ?

So, I am obliged to try to use XSL transformation to create another file, ant then load the file to have XPath selection into memory. (a lot of step).

Am I right or wrong ?
 
I precise. I think that if you use parse method of any parseur. The whole file will be loaded in memory.

In fact. My aims have changed a little (sorry but I'm in placement and it depends of my master)
Now I must use a stream(not a file) and I must select continueously from the stream the data answering to predefine selection options (like XPath ).

Do you know method or API which can do that. Or have you a method suggestion ?
 
You can read an IO stream like this @

Code:
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = null;
			if (strict) {
				factory.setNamespaceAware(true);
				factory.setValidating(true);
				builder = factory.newDocumentBuilder();
				builder.setErrorHandler(new XMLErrorHandler());
			} else {
				builder = factory.newDocumentBuilder();
			}

			Document doc = builder.parse(in);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top