Showing results for 
Search instead for 
Did you mean: 

Writing xml using Xerces library (C++) in NXOpen

Siemens Experimenter Siemens Experimenter
Siemens Experimenter



I am with empty xml document, I am trying to write xml document using Xerces Library(C++) in NXOpen. I am using following APIs createLSSerializer, setAttribute, createElement, createTextNode, createElementNS for this purpose. createLSSerializerAPI working Properly but when I try to set attributes using "setAttribute" function it throws an exceptioin.


Below is the sample code :



    const XMLCh *const  str = XMLString::transcode("LS");
    DOMImplementationLS *implementation = dynamic_cast<DOMImplementationLS*>(DOMImplementationRegistry::getDOMImplementation(str));
    DOMLSSerializer *serializer = implementation->createLSSerializer();


    const XMLCh *const  str1 = XMLString::transcode("xmlnsSmiley SurprisedtherNS");
    const XMLCh *const  str2 = XMLString::transcode("");

    DOMElement* rootElem = doc->getDocumentElement();
    rootElem->setAttribute(str1, str2);  //it's breaking here.


Kindly suggest the way to solve this problem.


Re: Writing xml using Xerces library (C++) in NXOpen

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

You may get a better response if you post your question in the NX programming and customization forum.