note 101472 deleted from book.simplexml by danbrown

From: Date: Sun, 19 Dec 2010 17:21:05 +0000
Subject: note 101472 deleted from book.simplexml by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175063@lists.php.net to get a copy of this message
Note Submitter: mail at binary dot me ---- //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;

« previous php.notes (#175063) next »