5#include <xercesc/dom/DOMElement.hpp>
6#include <xercesc/dom/DOMNodeList.hpp>
14 "<?xml version=\"1.0\" ?>"
15 "<!DOCTYPE TopElement ["
16 " <!ELEMENT TopElement (ChildElt*) >"
17 " <!ELEMENT ChildElt (ChildWithText | EmptyChild)* >"
18 " <!ATTLIST ChildElt anAttribute CDATA #REQUIRED >"
19 " <!ELEMENT ChildWithText (#PCDATA) >"
20 " <!ATTLIST ChildWithText attr CDATA #IMPLIED>"
21 " <!ELEMENT EmptyChild EMPTY> ]"
24 " <ChildElt anAttribute=\"I'm nested but empty\" />"
25 " <ChildElt anAttribute=\"I'm nested with content\">"
26 " <ChildWithText attr=\"text content\" >"
35 XERCES_CPP_NAMESPACE_USE
42 std::cout <<
"Document successfully parsed" << std::endl;
43 DOMElement* docElt = doc->getDocumentElement();
static void prettyPrintElement(DOMNode *elt, std::ostream &out, std::string prefix)
DOMDocument * parse(const char *const filename, const std::string &docType=std::string(""))
Parse an xml file, returning document node if successful.
std::string doc_string("<?xml version=\"1.0\" ?>" "<!DOCTYPE TopElement [" " <!ELEMENT TopElement (ChildElt*) >" " <!ELEMENT ChildElt (ChildWithText | EmptyChild)* >" " <!ATTLIST ChildElt anAttribute CDATA #REQUIRED >" " <!ELEMENT ChildWithText (#PCDATA) >" " <!ATTLIST ChildWithText attr CDATA #IMPLIED>" " <!ELEMENT EmptyChild EMPTY> ]" ">" "<TopElement>" " <ChildElt anAttribute=\"I'm nested but empty\" />" " <ChildElt anAttribute=\"I'm nested with content\">" " <ChildWithText attr=\"text content\" >" " Text content here." " </ChildWithText>" " <EmptyChild />" " </ChildElt>" "</TopElement>")
Test program for xml facility. Parse xml file and write it out to a stream.