I have to parse XML documents by using the XERCES C++ library for one of my C++ application. I am new to C++ application development so if anyone have done the parsing by using Xerces pls help me out here!!!!
i think i have the same problem ... i try to use Xerces as well, without major success.
So i can not give you much support, i am afraid. But i am not a complete newbie, maybe i can answer few basic questions ... if you have a specific question.
For example I have the below XML file from where I have extract the value of identification (ie)., I need to extract the "Newmember" string from the XMl. How can i do that using XPath in Xerces?
i do not know much about "XPath" ... this is a code snippet from Xerces samples and test codes downloaded with the sources ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
try \
{ \
XMLCh xpathStr[100]; \
XMLString::transcode(xpath,xpathStr,99); \
DOMXPathResult* result=(DOMXPathResult*)document->evaluate(xpathStr, document->getDocumentElement(), resolver, DOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE, NULL); \
if(result->getSnapshotLength() != expected) { \
fprintf(stderr, "DOMDocument::evaluate does not work in line %i (%d nodes instead of %d)\n", line, result->getSnapshotLength(), expected); \
OK = false; \
} \
result->release(); \
} \
catch(DOMException&) \
{ \
fprintf(stderr, "DOMDocument::evaluate failed at line %i\n", line); \
OK = false; \
}
I think what is interesting for you is the first lines ...
Maybe you have that already. What you will know best is how an xpathStr for your purpose would look like. I would guess
You can get single resultes with bool iterateNext ()
You can get the Nodes with the DOMNode * getNodeValue ()
With the nodes you can use "getAttribute" - methods and such stuff to extract all those values.
But you will have to look for that in the documentation anyway, there are nicer methods ...
I would be glad if you'd try some time and let me know if it worked or what didn't and i hope that helps you at least a bit. Best regards so far,
...