Req #51525 [Opn->Bgs]: Getting a node with a - in it

[email protected] Sat, 10 Apr 2010 05:12:19 +0200 (CEST)
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at http://bugs.php.net/bug.php?id=51525&edit=1

 ID:               51525
 Updated by:       [email protected]
 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