Hi
This is my first post on this board...
I am doing some work with XML..... I need to add some elements INTO the document and i am struggling
Here is an example of what the XML looks like (note: this is one part of the full doc)
<product>
<id>99</id>
<name>XXXXX</name>
<rate>
<id>55</id>
<price>55.00</price>
</rate>
<rate>
<id>44</id>
<price>333.00</price>
</rate>
</product>
the code loops around and outputs the "rate" nodes and its values onto the price page, I now need it to add X number of blank "rate" nodes to the doc so the code will output empty stuff , the whys and wheres etc are not important.
I tried the below:
$prod_xml = $prod->asXML();
$dom = new DOMDocument();
$dom->loadXML($prod->asXML());
$element = $dom->createElement("rate");
$dom->appendChild($element);
$prod_new = $dom->saveXML();
However I got the following
.......
</product>
<rate></rate>
I need the empty rate to be inside the product node , and I am unsure how to do it ....
I hope this makes sense ...