Hello all,
 
I'm trying to use PHPxml for working with XML document. Everyting works fine except adding the new nodes. Frankly speaking, method add_node doesn't work.
 
It returns path for the new node, but when I'm trying to get the results and show them or save it to file - I see NO new node that had been added.
 
Please take a look at my code:

<?
// Include the <phpXML/> class.
include("lib/xml.php");
 
// Create an XML object for the XML file.
$xml = new XML("some.xml");
 
$nn = $xml->add_node("/", "node");
$fp = fopen("some2.xml","w+");
// characters translation
$trans = get_html_translation_table(HTML_ENTITIES);
$trans = array_flip($trans);
$xs = strtr($xml->get_file(), $trans);
// write
fputs($fp, $xs);
fclose($fp);
 
?>

file SOME.XML:
 
<?xml version="1.0" encoding="UTF-8"?>
<root/>

get_file methid returns original XML - simply <root/>. Note that I tried different variations of path parameter string in add_node method. (ie "root/", "/root", ".", "/", "/root/"... and so on)
 
When I 'm trying to get the path for the new created node I get a result - root/node[1]. But there no new node in the xml.
 
Please, can you explain me why this happens? Or maybe I'm using add_node not very correctly?
 
Serge.

Reply via email to