RE: Filtering XML with SAX
"Lang Yun" <[email protected]>
| Newsgroups | gmane.text.xml.sax.general |
|---|---|
| Message-ID | <53D1A1225371BB42A5932043D4F4D7BE02E6254C@msgpetmb1.amer.ads.autodesk.com> |
You can check for a match in startElement, and if a match is found, in endElement, you can store the value on your content handler (characters(). You can retrieve the values from your content handler after parsing is done. Lang -----Original Message----- From: Mael Guillemot [mailto:[email protected]] Sent: February 28, 2003 4:36 AM To: [email protected]; Mael Guillemot Subject: [Sax-users] Filtering XML with SAX Hello, I use Xerces-C++ on Linux (Redhat 7.2). I compiled and built the samples (SAXCount, SAXPrint, PParse) and everything is OK. I guess most of you use Java but the idea of my question should be independant of the platform. I want to filter (to extract elements information from) my XML files (eg. representing key-frames of videos like this): <video> <shot> <keyframe-timestamp>000020.000</keyframe-timestamp> </shot> <shot> <keyframe-timestamp>000030.000</keyframe-timestamp> </shot> ... and I want to extract the values of the elements of <keyframe-timestamp>. I could use easily XSLT to transform into HTML but I want these values for printing them later on a HTML file like this. { My question is not related to how to produce the HTML file but how to extract information from XML file }. <html> shot 1: <img src='http://www.website.com/cgi-bin/getframecgi?filename=video.avi×tamp=000020.000' width='100' height='70' > <br> shot 2: <img src='http://www.website.com/cgi-bin/getframecgi?filename=video.avi×tamp=000030.000' width='100' height='70' > <br> ... I think I can use SAX API for that but I can't find any functions to extract information. How do I extract elements using a handler class like in SAXPrint (I understand only startelement and endelement functions)? Do you advise me to use DOM with getNode functions instead, do you have any sample code to guide me? Thanks a lot for any help, Maël ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ List: [email protected] See: http://www.saxproject.org https://lists.sourceforge.net/lists/listinfo/sax-users ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com _______________________________________________ List: [email protected] See: http://www.saxproject.org https://lists.sourceforge.net/lists/listinfo/sax-users