Req #51525 [Opn->Bgs]: Getting a node with a - in it
| From: | aharvey@php.net | Date: | Sat, 10 Apr 2010 03:12:19 +0000 |
| Subject: | Req #51525 [Opn->Bgs]: Getting a node with a - in it | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-149469@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51525&edit=1
ID: 51525
Updated by: aharvey@php.net
Reported by: martin at aarhof dot eu
Summary: Getting a node with a - in it
-Status: Open
+Status: Bogus
Type: Feature/Change Request
Package: SimpleXML related
Operating System: Windows
PHP Version: 5.2.13
New Comment:
Given that - already has another meaning in PHP, no, not really.
Previous Comments:
------------------------------------------------------------------------
[2010-04-10 04:12:47] martin at aarhof dot eu
Solution is
echo $channel->{"display-name"};
Could this be fixed so you dont need the {} ?
------------------------------------------------------------------------
[2010-04-10 03:56:21] martin at aarhof dot eu
Description:
------------
If a XML node have a - in it you can't get the data from it
<display-name>
echo $channel->display-name;
Notice: Use of undefined constant name - assumed 'name'
Test script:
---------------
<?xml version="1.0" encoding="UTF-8" ?>
<tv generator-info-name="www.ontv.dk/xmltv">
<channel id="www.ontv.dk/tv/1">
<display-name lang="dk">DR1 DK</display-name>
</channel>
</tv>
$xml = simplexml_load_string($xml);
$channels = $this->xml->xpath('//channel');
foreach($channels AS $channel) {
echo $channel->display-name;
}
Expected result:
----------------
DR1 DK
Actual result:
--------------
Notice: Use of undefined constant name - assumed 'name'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51525&edit=1