[phpXML] Answers to Olivers three questions
Brought to you by:
bs_php,
nigelswinson
From: <nig...@us...> - 2001-10-08 18:04:10
|
RE: [phpXML] Re: xml.php locationThe first thing you need to do is go get t= he 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?=20 Use the exportToFile() method function exportToFile($fileName, $absoluteXPath=3D'', $xmlHeader=3D'<?x= ml version=3D"1.0"?>') http://www.carrubbers.org/scripts/php/xmlphp/doc/PhpXmlDocumentation.php#ex= portToFile How to add a node to an XML file. add_node does not seem to work.=20 Please advise.=20 Use the appendData() method function appendData($absoluteXPath, $value) Note that the parameter is an "absolute X Path" expression, not just any ol= d x path expression, so it must address 1 unique node. ie "/root[1]/record= s[4]" not "/root/record[4]". http://www.carrubbers.org/scripts/php/xmlphp/doc/PhpXmlDocumentation.php#ap= pendData How do I get attributes by the XPath function in phpxml?=20 I want to do something like in this code:=20 $results =3D $xml->evaluate("//users/user[@us_workspace=3D$workspace]/pro= duct[@us_prname=3D$product]");=20 file://Display user in list=20 $attributes =3D array();=20 foreach ($results as $users) {=20 file://username=20 $attributes =3D $xml->get_attributes("parent::".$users);=20 Use the getAttributes method function getAttributes($absoluteXPath, $attribute =3D '') Note again the absolute X path expression. If you pass an array in, then i= t won't work. If you want just the one attribute, then you can specify it,= otherwise you get all the attributes in an array. http://www.carrubbers.org/scripts/php/xmlphp/doc/PhpXmlDocumentation.php#ge= tAttributes Cheers Nigel =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D For the most recent version of phpxml, V1.N.X, and an archive of this list = visit: http://www.sourceforge.net/projects/phpxmldb -- This message has been sent through the <phpXML/> user discussion list. To u= nsubscribe, please visit https://sslsites.de/mailinglisten/user/user@lists.= phpxml.org/ |