php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mbishton at yahoo dot com
New email:
PHP Version: OS:

 

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

Many of the elements have dashes in them. For example:
<totals-by-party-header>
<party-header>Party</party-header>
<yea-header>Yeas</yea-header>
<nay-header>Nays</nay-header>
<present-header>Answered ?Present?</present-header>
<not-voting-header>Not Voting</not-voting-header>

Any reference to an element, like;
$xml->totals-by-party-header->party-header->yea-header 
will not work.



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

In the following example, $test will produce an error. 
simplexml_load_file('http://clerk.house.gov/evs/1999/roll610.xml') ;
$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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-02 17:27 UTC] derick@php.net
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 http://www.php.net/support.php 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-2022 The PHP Group
All rights reserved.
Last updated: Sat Oct 01 20:05:53 2022 UTC