BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
test_mem.cxx
Go to the documentation of this file.
1/// Test program for xml facility. Parse xml file and write it out to a stream.
2
3#include "xmlBase/XmlParser.h"
4#include "xmlBase/Dom.h"
5#include <xercesc/dom/DOMElement.hpp>
6#include <xercesc/dom/DOMNodeList.hpp>
7
8#include <string>
9#include <iostream>
10#include <fstream>
11
12std::string doc_string
13(
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> ]"
22 ">"
23 "<TopElement>"
24 " <ChildElt anAttribute=\"I'm nested but empty\" />"
25 " <ChildElt anAttribute=\"I'm nested with content\">"
26 " <ChildWithText attr=\"text content\" >"
27 " Text content here."
28 " </ChildWithText>"
29 " <EmptyChild />"
30 " </ChildElt>"
31 "</TopElement>"
32 );
33
34int main() {
35 XERCES_CPP_NAMESPACE_USE
36
37 xmlBase::XmlParser parser;
38
39 DOMDocument* doc = parser.parse(doc_string);
40
41 if (doc != 0) { // successful
42 std::cout << "Document successfully parsed" << std::endl;
43 DOMElement* docElt = doc->getDocumentElement();
44 xmlBase::Dom::prettyPrintElement(docElt, std::cout, "");
45 }
46 return(0);
47}
48
49
50
static void prettyPrintElement(DOMNode *elt, std::ostream &out, std::string prefix)
Definition: Dom.cxx:644
DOMDocument * parse(const char *const filename, const std::string &docType=std::string(""))
Parse an xml file, returning document node if successful.
Definition: XmlParser.cxx:108
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.
int main()
Definition: test_mem.cxx:34