26 #include <xercesc/dom/DOMImplementation.hpp>
27 #include <xercesc/dom/DOMImplementationLS.hpp>
28 #include <xercesc/dom/DOMImplementationRegistry.hpp>
29 #include <xercesc/dom/DOMWriter.hpp>
30 #include <xercesc/framework/MemBufFormatTarget.hpp>
39 const XMLCh * propertyCanonical = xercesc::XMLUni::fgDOMWRTCanonicalForm;
40 const XMLCh * propertyPrettyPrint = xercesc::XMLUni::fgDOMWRTFormatPrettyPrint;
41 xercesc::DOMImplementation *impl =
42 xercesc::DOMImplementationRegistry::getDOMImplementation(
U(
"LS"));
43 xercesc::DOMWriter *xercesWriter =
44 ((xercesc::DOMImplementationLS*)impl)->createDOMWriter();
46 if (xercesWriter->canSetFeature(propertyPrettyPrint, mShouldIndent))
47 xercesWriter->setFeature(propertyPrettyPrint, mShouldIndent);
48 if (xercesWriter->canSetFeature(propertyCanonical, mShouldCanonicalize))
49 xercesWriter->setFeature(propertyCanonical, mShouldCanonicalize);
51 xercesc::MemBufFormatTarget * xercesTarget =
new xercesc::MemBufFormatTarget();
52 xercesWriter->writeNode(xercesTarget, *node);
53 const char * buffer = (
char *) xercesTarget->getRawBuffer();
54 const unsigned bufferLen = xercesTarget->getLen();
55 target << std::string(buffer,bufferLen);