|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32544 cannot parse elements with dashes in names
Submitted: 2005-04-02 17:20 UTC Modified: 2005-04-02 17:27 UTC
From: mbishton at yahoo dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.0.3 OS: Windows XP Prof. Version 5.1.260
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mbishton at yahoo dot com
New email:
PHP Version: OS:


 [2005-04-02 17:20 UTC] mbishton at yahoo dot com
U.S. library of congress displays house voting activity in xml file. For example: $xml = simplexml_load_file('') ;

Many of the elements have dashes in them. For example:
<present-header>Answered ?Present?</present-header>
<not-voting-header>Not Voting</not-voting-header>

Any reference to an element, like;
will not work.

Reproduce code:
It works just fine if the element does not have dashes in it, like:
simplexml_load_file('') ;
$vmeta = $xml->xpath('//vote-metadata' ); 
echo 'congress = ' . $vmeta[0]->congress ; 

In the following example, $test will produce an error. 
simplexml_load_file('') ;
$meta = $xml->xpath('//totals-by-party' ); 
$test = $meta[1]->yea-total ; 

Expected result:
I expected it to return an array or the content of an element, depending on what I was referencing. 

Actual result:

Notice: Use of undefined constant total - assumed 'total' in C:\Program Files\Apache2\htdocs\test01.php on line 9


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-02 17:27 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

 [2011-01-18 22:06 UTC] thinkswan at gmail dot com
You must encapsulate entries containing dashes.

$test = $meta[1]->{'yea-total'}; will work.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 23:01:29 2024 UTC