Question

i have currently generated some XML using xercer in C++, using the following code:

           XMLCh tempAttribute[100];
           XMLString::transcode("ad", tempStr, 99);
           doc = impl->createDocument(0,tempStr ,0);
           root = doc->getDocumentElement();
           XMLString::transcode("imageAd", tempStr, 99);
           element = doc->createElement(tempStr);
           root->appendChild(element);

However i am attempting to get the attributes within the top "ad" element (as below), however i have had little luck in doing so, can someone with experience using xerces please advise.

Thanks in advance!

<ad xsi:noNamespaceSchemaLocation="smaato_ad_v0.9.xsd" modelVersion="0.9">
    <imageAd>
Was it helpful?

Solution

maybe you didn't saw the call to setAttribute in my previous answer but you can set any attribute for any element with calls like

root->setAttribute(L"modelVersion", L"0.9");
root->setAttribute(L"xsi:noNamespaceSchemaLocation", L"xsi:noNamespaceSchemaLocation");

Where root is the pointer to your root element.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top