note 101472 added to book.simplexml
| From: | mail at binary dot me | Date: | Sun, 19 Dec 2010 01:30:55 +0000 |
| Subject: | note 101472 added to book.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175049@lists.php.net to get a copy of this message | ||
//load XML with Simple XML. LIBXML_NOCDATA is used to load information from CDATA Nodes
automatically. They are resolved to normal text and inserted into the parent Node
$sxml = simplexml_load_file(_PATHXML, NULL, LIBXML_NOCDATA);
//get XML Root Name
echo $sxml->getName();
//navigate through Simple XML. xpath return an ARRAY with found Nodes
var_dump( $sxml->xpath($nodeName) );
//get the first Node, found through an xpath Expression
$nodesArray = $sxml->xpath($nodeName);
var_dump( $nodesArray[0] );
//check if Node Exists
if($sxml->xpath('Path/to/Node'))
echo ('exists'); echo '<br>';
//empty array is returned if no such node exists
var_dump($sxml->xpath('Path/to/Node'));
//Entering the Node directly
var_dump( $sxml->middle->text );
//getting the Value, saved inside the node as String
echo (string)$sxml->middle->text;
----
Server IP: 69.147.83.197
Probable Submitter: 78.49.13.113
----
Manual Page -- http://www.php.net/manual/en/book.simplexml.php
Edit -- https://master.php.net/note/edit/101472
Del: integrated -- https://master.php.net/note/delete/101472/integrated
Del: useless -- https://master.php.net/note/delete/101472/useless
Del: bad code -- https://master.php.net/note/delete/101472/bad+code
Del: spam -- https://master.php.net/note/delete/101472/spam
Del: non-english -- https://master.php.net/note/delete/101472/non-english
Del: in docs -- https://master.php.net/note/delete/101472/in+docs
Del: other reasons-- https://master.php.net/note/delete/101472
Reject -- https://master.php.net/note/reject/101472
Search -- https://master.php.net/manage/user-notes.php