note 101967 added to book.simplexml

From: Date: Thu, 20 Jan 2011 17:07:33 +0000
Subject: note 101967 added to book.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-175941@lists.php.net to get a copy of this message
An easer way to get the text node if you can't access to [0] property of the simpleXMLElement is to use the sprintf function. As gwhitescarver at yahoo dot com said, in some version of php 5 it is hard to access to text node of an element, but when you print the element, the [0] property is automaticaly returned. Like if you echo() the element, the text node is return. The sprintf function do the same: $a = array(); foreach ($xml->children() as $child) { $a[$child->getName()] = sprintf("%s", $child); } ---- Server IP: 69.147.83.197 Probable Submitter: 207.134.168.76 ---- Manual Page -- http://www.php.net/manual/en/book.simplexml.php Edit -- https://master.php.net/note/edit/101967 Del: integrated -- https://master.php.net/note/delete/101967/integrated Del: useless -- https://master.php.net/note/delete/101967/useless Del: bad code -- https://master.php.net/note/delete/101967/bad+code Del: spam -- https://master.php.net/note/delete/101967/spam Del: non-english -- https://master.php.net/note/delete/101967/non-english Del: in docs -- https://master.php.net/note/delete/101967/in+docs Del: other reasons-- https://master.php.net/note/delete/101967 Reject -- https://master.php.net/note/reject/101967 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175941) next »