0

I have a method which compares two XML documents (via streams) and writes the output to a Writer. The end result is that I want to then parse this into an in memory DOM document without creating an intermediary string, file or in memory structure.

My problem is that I can't figure out how to push the data from my writer into say a SAXHandler to create my DOM document.

I have it setup right now to just write the result to stdout (Note i1 and i2 are InputStream's for my original documents which I am comparing):

BufferedReader inputReader1 = new BufferedReader(new InputStreamReader(i1));
BufferedReader inputReader2 = new BufferedReader(new InputStreamReader(i2));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
(new XMLCompare()).compare(inputReader1, "",inputReader2, "", writer);

So instead of writing the result of compare() to stdout I want to build a DOM document with it. Any suggestions?

Thanks!

4

1 回答 1

0

难道你不想做这样的事情 - http://www.java-tips.org/other-api-tips/jdom/converting-from-jdom-to-sax-supported-in-jdom-1.9-3 .html

于 2013-10-10T20:47:32.810 回答