This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes SAx and XML Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "SAx and XML" Watch "SAx and XML" New topic
Author

SAx and XML

francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 155
Respected Sirs,

Is it possible to, using the SAX approach, extract the XML content between an opening and closing tag as if it was a continuous string of text?

For example, let's say we have the following document:

<one>
<two>
<three>data one</three>
<four>data two</four>
</two>
</one>

Is it possible to directly extract the content between <one> and </one>
as if it was a text string?

Thanks
Francis
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Yes you can.
But there's a small catch. Check this thread.
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
oops sorry.. misread the question..
well you could always code for such logic..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16487
    
    2

Gamini is right, the answer is "yes".

But if you can't see how, I would suggest you convert a start-element event to a string containing a representation of an element's start tag, and so on. You won't necessarily get an exact representation of what's there, for example you may get attributes in a different order and you may represent empty elements differently, but that's allowed by the rules of XML.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: SAx and XML
 
Similar Threads
AJAX ( problem while retrieving xml data from the jsp)
How do I assign variables with values from a list?
Formatting xml using java
sax parsing problem
some notes on xml