|
Re: Starting To Use Xerces: msg#00037text.xml.xerces-c.user
At 16.15 14/12/2006 -0800, appleGuy wrote: Hi, The XML is well-formed; but I would rather use this structure, in order to avoid complex application logic to associate a question with its answer: <_questions> <question> <q>What Is 5 x 3?</q> <a>15</a> </question> <question> <q>What Is 5 x 5?</q> <a>25</a> </question> <question> <q>What Is 5 + 5?</q> <a>10</a> </question> </_questions> (IF OK): I need to know how to use the parser to parse this file & dump the DOMBuilder will build a DOM tree that you will have to navigate (DOMDocument->getDocumentElement() will give you the pointer to the "loopcardprj" node; from there, getFirstChild()/getNextSibling() will give you either text nodes containing whitespace or the "_prjsetup"/"_questions" element; and so on.. until you will find some text nodes containing the real data). Alternatively you can use a SAXParser or a SAX2XMLReader that will convert the file into a sequence of callbacks (start "loopcardprj" element; start "_prjsetup" element; start "title" element; found data "untitled"; end "title" element...); if you just need to convert the XML file into a C++ data structure, this would be the choice I would made. Alberto Please If you could help, im really new to this XML / Parsing Business... |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Starting To Use Xerces: 00037, appleGuy |
|---|---|
| Next by Date: | Re: Starting To Use Xerces: 00037, appleGuy |
| Previous by Thread: | Starting To Use Xercesi: 00037, appleGuy |
| Next by Thread: | Re: Starting To Use Xerces: 00037, appleGuy |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |