Hi,
I have written a small function that dumps portions of the DOM tree (rooted
at nodes with the specified tag name) to a file [see below]. Obviously the
output file does not have a root node. How can I make the output file a
proper XML file (with a single root node)? I have tried a few things, but
nothing seems to work. My function follows:
#define SPECIFIED_TAG “yadayada”
void
serializeSubtree (DOMNode* node, DOMWriter *theSerializer, XMLFormatTarget
*target)
{
if(!node) return;
const char* name = XMLString::transcode(node->getNodeName());
if(!strcmp(name, SPECIFIED_TAG))
{
theSerializer->writeNode(target, *node);
}
for (DOMNode* childNode (node->getFirstChild ()); childNode;
childNode = childNode->getNextSibling ())
{
serializeSubtree(childNode, theSerializer, target);
}
}
Thanks,
Kong
--
View this message in context:
http://www.nabble.com/Carving-out-a-subset-of-XML-content-into-a-separate-XML-file-tp14627707p14627707.html
Sent from the Xerces - C - Users mailing list archive at Nabble.com.