You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Kishore <ki...@irislogic.com> on 2000/10/04 00:00:06 UTC

How to Get DOM_Document object for a XML file

Hi 

I am using xerec-c libraries for creating and updating, parsing XML files.

I want to create DOM_Document object with the data given in a XML file...

What I want to do here is, once I have XML file, I want add or delete, modify the elements in
the xml file. For this I need to create DOM_Document object from the XML file given.

Would anyone tell me what classes I need to use and How to proceed ?

Thanks
Kishore


Re: How to Get DOM_Document object for a XML file

Posted by M Nair <ma...@mediaone.net>.
Hi.

I guess the snippet of code below would accomplish what you want -

buffer is char * that contains the XML file to be parsed.

MemBufInputSource   input((XMLByte*)buffer, strlen(buffer), "1");

    parser.setValidationScheme(DOMParser::Val_Auto);
    parser.setDoNamespaces(false);
    parser.setErrorHandler(&errorHandler);
    parser.setExpandEntityReferences(false);
    parser.setToCreateXMLDeclTypeNode(true);

    try
    {
 parser.parse(input);
 document = parser.getDocument();
    }
and return the document. Does that solve your problem?

Once you have the document tree, you can manipulate the elements contained.

M

Kishore wrote:

> Hi
>
> I am using xerec-c libraries for creating and updating, parsing XML files.
>
> I want to create DOM_Document object with the data given in a XML file...
>
> What I want to do here is, once I have XML file, I want add or delete, modify the elements in
> the xml file. For this I need to create DOM_Document object from the XML file given.
>
> Would anyone tell me what classes I need to use and How to proceed ?
>
> Thanks
> Kishore
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org