|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-04-10 03:56 UTC] 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'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 22:00:01 2025 UTC |
Solution is echo $channel->{"display-name"}; Could this be fixed so you dont need the {} ?