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)
Code: Select all
<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>
I tried the below:
Code: Select all
$prod_xml = $prod->asXML();
$dom = new DOMDocument();
$dom->loadXML($prod->asXML());
$element = $dom->createElement("rate");
$dom->appendChild($element);
$prod_new = $dom->saveXML();
Code: Select all
.......
</product>
<rate></rate>
I hope this makes sense ...
Moh