This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I want to search an xml-file using the SAX-parser. Like, show all nodes where the personid-node equals 001. Im having a hard time understanding XML and SAX in generall. Can anyone help me, point me in tha right direction? I have tried to use the ranchs wiki faq tutorial. But it didnt help so much...
Perhaps I should start with the DOM but the task rquiers using SAX. And the Sun-Tutorial is very long, Im looking for something shorter. I found something at the The Java Developers Almanac (http://www.javaalmanac.com/egs/javax.xml.parsers/BasicSax.html) but its only parse the xml-file. I want to the parser to print out every childnode to every node called <person>.
Even better, use of XPath (as in XSLT) would be better (with Xalan for instance). The XPath expression for returning all the person whose id nodes equals to 1 would look something like:
For instance, in the following xml document there are a number of person nodes:
The following code will display the person with id 001:
Joined: Nov 22, 2008
Sebastian, If you'd like to use Sax events, it's another story as no document tree is available. Given the same xml file as before, the following code uses Sax to render the found person:
Of course this code is incomplete and just fits the simple example, but that should give you an idea of what to do to get the job done. Cheers
Joined: Jan 30, 2004
Thanks for your tips I will check them out right away (have been busy for a while). Im aware of the XPath, Im getting to soon but I need to understand the basic first. The next task will be XPath related. Thanks!