For example, my XML file looks like this:
Code: Select all
<content>
<category link="0">
<title>Animals</title>
<xml>animals.xml</xml>
</category>
<category link="1">
<title>Bears</title>
<xml>Bears.xml</xml>
</category>
</content>
If I were to add another line to this xml file, the 'link' attribute of category tag would need to increase to 2.
The PHP code I am currently using to add data to the XML file looks like this:
Code: Select all
$str = $_SESSION['name'];
$file = PREG_REPLACE("/[^0-9a-zA-Z]/i", '', $str);
if (isset($str) && !empty($str)) {
$simp = simplexml_load_file('galleries.xml');
$node = $simp->addChild('category');
$node->addChild('title', $str);
$node->addChild('xml', 'uploadify/xml/'.$file.'.xml');
$s = simplexml_import_dom($simp);
$s->saveXML('galleries.xml');
}