First, I would like to say that I am using an XML parser written by Frank Vanden Bergen and recently trying to switch to Pugixml. I find the transition bit complicated. Hope to get help here.
Question: How can I build a tree from scratch for a little xml below using pugixml APIs? I tried to learn the examples on the pugixml homepage, but most of them are hardcoded with root node values. I mean
if (!doc.load("<node id='123'>text</node>", pugi::parse_default | pugi::parse_comments)) return -1;
hardcoded. I also tried reading about the xml_document and xml_node documentation, but couldn't figure out where to start if I needed to build a tree from scratch.
#include "pugixml.hpp"
XML:
<?xml version="1.0" encoding="UTF-8"?> <d:testrequest xmlns:d="DAV:" xmlns:o="urn:example.com:testdrive"> <d:basicsearch> <d:select> <d:prop> <o:versionnumber/> <d:creationdate /> </d:prop> </d:select> <d:from> <d:scope> <d:href>/</d:href> <d:depth>infinity</d:depth> </d:scope> </d:from> <d:where> <d:like> <d:prop> <o:name /> </d:prop> <d:literal>%img%</d:literal> </d:like> </d:where> </d:basicsearch> </d:testrequest>
I could see most of the examples published on how to read / parse xml, but I could not find how to create it from scratch.
c ++ xml pugixml
Sandeep
source share