aspose file tools
The moose likes XML and Related Technologies and the fly likes SAX -- DOM? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "SAX -- DOM?" Watch "SAX -- DOM?" New topic
Author

SAX -- DOM?

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24039
    
  13

I'm working on implementing a badly-designed API. I find myself in a spot where I've got a SAX parser for a given document format, and I need to implement a method that's handing me an org.w3c.dom.Element representing the root of a DOM model for that same format.

Without writing a DOM version of the parser, and without bouncing the DOM off the disk as XML (which itself is far trickier than it ought to be -- ) is there any relatively simple way, using only API classes, to walk the DOM tree and feed the SAX parser?


[Jess in Action][AskingGoodQuestions]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
Something like this, I guess:


"I'm not back." - Bill Harding, Twister
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24039
    
  13

Works great! I knew there had to be an easy way to do this!
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
Cool. Note that if you do find yourself needing to convert to/from XML, you may also want to look at StreamResult and StreamSource.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SAX -- DOM?
 
Similar Threads
How to read XML without SAX or DOM parser
Difference between SAX parser and DOM Parser
Design pattern in SAX parser.
Jaxp parser!!, Parsing with Jaxp API!!
Junit For testing SAX API