note 61219 added to ref.simplexml

From: Date: Sat, 28 Jan 2006 14:45:00 +0000
Subject: note 61219 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-102621@lists.php.net to get a copy of this message
As noted by paul at preinheimer dot com in a lower note ( http://us3.php.net/manual/en/ref.simplexml.php#52583 ); If you want to access an element that has a dash in its name, (as is common with the XML documents provided by the Library of Congress, as well as the NWS) you will need to handle it a little bit differently. You can either use XPATH, which works fine, but will return an array of results every time, even if there is a single result. eg. $xml->xpath('/data/time-layout/start-valid-time'} You can also choose just to encapsulate the element names containing a dash: $xml->data->{'time-layout'}->{'start-valid-time'} ---- Server IP: 216.194.113.175 Probable Submitter: 68.110.115.17 ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61219 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61219&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61219&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61219&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61219&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61219&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61219&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61219&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61219&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102621) next »