Title: RE: [phpXML] Re: xml.php location

The first thing you need to do is go get the latest version, ie 1.N.5.  Available from phpxml's 1.N.X's home at http://www.sourceforge.net/projects/phpxmldb

How do I save an altered XML document using PHPXML?

Use the exportToFile() method

    function exportToFile($fileName, $absoluteXPath='', $xmlHeader='<?xml version="1.0"?>')


How to add a node to an XML file. add_node does not seem to work.
Please advise.

Use the appendData() method

    function appendData($absoluteXPath, $value)

Note that the parameter is an "absolute X Path" expression, not just any old x path expression, so it must address 1 unique node.  ie "/root[1]/records[4]" not "/root/record[4]".

How do I get attributes by the XPath function in phpxml?
I want to do something like in this code:

$results = $xml->evaluate("//users/user[@us_workspace=$workspace]/product[@us_prname=$product]");
file://Display user in list
$attributes = array();
foreach ($results as $users) {
 $attributes = $xml->get_attributes("parent::".$users);

Use the getAttributes method
    function getAttributes($absoluteXPath, $attribute = '')
Note again the absolute X path expression.  If you pass an array in, then it won't work.  If you want just the one attribute, then you can specify it, otherwise you get all the attributes in an array.
For the most recent version of phpxml, V1.N.X, and an archive of this list visit:  http://www.sourceforge.net/projects/phpxmldb

Reply via email to