Dear friends,

I 'm new in Xerces so don't count on me very much.

DOMParser parses an xml file and creates an xml tree.
Then you can get a reference on the tree and change it
(add new elements, erase some etc.) with DOMDocument and
write it to an xml file with DOMWriter.
Example:
XercesDOMParser* parser = new XercesDOMParser();
.
//some flags eg. parser->setDoSchema(true);
.

try{
        parser->parse(your_xml_file);
}
catch(const XMLException& toCatch)
{
        char* message = XMLString::transcode(toCatch.getMessage());
        cout << "Exception message is : \n"
             << message << "\n";
        XMLString::release(&message);
        return -1;
}

DOMDocument* doc = parser->getDocument();
DOMNode* root = doc->getDocumentElement();

.
//Manipulate the tree
.

DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(0);
DOMWriter* writer = ((DOMImplementationLS*)impl)->createDOMWriter();
LocalFileFormatTarget myFormTarget(your_file_name);

//And after all that, you can write your xml tree in a file
try
{
        writer->writeNode(&myFormTarget , *root);
}
catch(...) { cout << "Unexpected error.\n"; }
writer->release();

delete parser;


//Finish


I use it and it works.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to