[ miniplazma @ 02.06.2012. 22:17 ] @
Imam sledeći XML file :
Code:

<?xml version="1.0" encoding="utf-8"?>
<videoGallery>
<header title="VIDEO GALERIJA"/>
<footer><![CDATA[<font color="#ffffff"><a href="mailto:[email protected]">info<font color="#c0ff00">@</font>loremipsumdolor.com</a></font>]]></footer>
<items>
    <item  item_icon="items/icon5.jpg" item="items/video1.flv" title="Video 1 Category 1"><![CDATA[Opis.]]></item>
</items>
</videoGallery>


Pokušam da dodam novi item sa php, ali ne dobijam odgovarajući.
PHP kod:
Code:

<?php
$xml = simplexml_load_file("content.xml"); //This line will load the XML file.

$sxe = new SimpleXMLElement($xml->asXML()); //In this line it create a SimpleXMLElement object with the source of the XML file.
//The following lines will add a new child and others child inside the previous child created.
$item = $sxe->addChild("item");
$item->addChild("item_icon", "../items/ddk.jpg");
$item->addChild("item", "items/video1.flv");
$item->addChild("title","naslov");
$item->addChild("item","nekakav dygi tekst");
//This next line will overwrite the original XML file with new data added
$sxe->asXML("content2.xml"); 
?>


Nadovezuje ovo:
Code:
<item>
      <item_icon>../items/ddk.jpg</item_icon>
      <item>items/video1.flv</item>
      <title>naslov</title>
      <item>opis</item>
</item>


[ Jbyn4e @ 03.06.2012. 06:44 ] @
Koliko vidim tebi treba ne addchild vec addattribute:
http://www.php.net/manual/en/simplexmlelement.addattribute.php