本文整理汇总了C++中DOMLSSerializer::writeToString方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMLSSerializer::writeToString方法的具体用法?C++ DOMLSSerializer::writeToString怎么用?C++ DOMLSSerializer::writeToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMLSSerializer
的用法示例。
在下文中一共展示了DOMLSSerializer::writeToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertDomToString
string XmlUtil::convertDomToString() {
if(!doc)
throw "DOM is empty"; // FIXME add an exception type for this
DOMImplementationLS* implLS = dynamic_cast<DOMImplementationLS*>(impl);
DOMLSSerializer* theSerializer = implLS->createLSSerializer();
DOMConfiguration* serializerConfig = theSerializer->getDomConfig();
if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
serializerConfig->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
string stringTemp = XMLString::transcode (theSerializer->writeToString(doc));
theSerializer->release();
/*string stringDump;
for (string::iterator it = stringTemp.begin() ; it < stringTemp.end(); ++it) {
if (!isspace (*it))
stringDump += *it;
}
return stringDump;*/
return stringTemp;
}
示例2: transcode
string tsp::Tool::xmlNode2String(const DOMNode* node) {
if (!initXmlEngine())
return NULL;
DOMImplementation *implementation =
DOMImplementationRegistry::getDOMImplementation(
XMLString::transcode("LS"));
// Create a DOMLSSerializer which is used to serialize a DOM tree into an XML document.
DOMLSSerializer *serializer =
((DOMImplementationLS*) implementation)->createLSSerializer();
// Make the output more human readable by inserting line feeds.
if (serializer->getDomConfig()->canSetParameter(
XMLUni::fgDOMWRTFormatPrettyPrint, true))
serializer->getDomConfig()->setParameter(
XMLUni::fgDOMWRTFormatPrettyPrint, true);
// The end-of-line sequence of characters to be used in the XML being written out.
serializer->setNewLine(XMLString::transcode("\r\n"));
return XMLString::transcode(serializer->writeToString(node));
}