Edit report at http://bugs.php.net/bug.php?id=32544&edit=1

 ID:                 32544
 Comment by:         thinkswan at gmail dot com
 Reported by:        mbishton at yahoo dot com
 Summary:            cannot parse elements with dashes in names
 Status:             Bogus
 Type:               Bug
 Package:            SimpleXML related
 Operating System:   Windows XP Prof. Version 5.1.260
 PHP Version:        5.0.3
 Block user comment: N
 Private report:     N

 New Comment:

You must encapsulate entries containing dashes.



$test = $meta[1]->{'yea-total'}; will work.


Previous Comments:
------------------------------------------------------------------------
[2005-04-02 17:27:58] der...@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.

.

------------------------------------------------------------------------
[2005-04-02 17:20:32] 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


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=32544&edit=1

Reply via email to