• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

Do i need DOMDocument in order to append a new child node ?

hi have this part of the xml in my class:

<carController>
      <car max="160" min="0"/>    
</carController>


i dont have a pointer to the DomDocument... anyway here is an example of what i tried instead, but it does not work:

xercesc::DOMElement *carController= getDOMConfig(); // this gives me MY CONFIG the one above
xercesc::DOMNode *newCar = carController->getFirstChild()->cloneNode( false );  // this doesnt work
xercesc::DOMElement *car = static_cast<xercesc::DOMElement *>(carController->
            appendChild( newCar ));  // therfore this wont work also.
// ... here comes the saving the changes stuff

I am lost in what else to do.

How can I create a newCar node, in order for me to insert it into my  carController node? Also If it doesnt have any child nodes yet.

Thank you.



0
Endelm
Asked:
Endelm
1 Solution
 
EndelmAuthor Commented:
i found it, i did like this:
xercesc::DOMElement *carController= getDOMConfig();
xercesc::DOMDocument *config = carController->getOwnerDocument;
xercesc::DOMElement *newCar = config->createElement(xercesc::XMLString::transcode("car"));
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now