From:             nickmaccarthy at gmail dot com
Operating system: Ubuntu 8.04
PHP version:      5.2.9
PHP Bug Type:     SimpleXML related
Bug description:  Will not parse tags with certain chars

Description:
------------
Note:  SimpleXML has issues parsing tags with ":" in it.

GML tags for example are formatted like:
<gml:name>Foo</gml:name>.

In the SimpleXML Documentation, it states to put tags between {} that
could contain chars. that could break the parser, like "-" for example. 

In our example below:
$xml->firstLayer->secondLayer->{'gml:name'} 

will not be parsed by SimpleXML, but SimpleXML will NOT throw an error or
lead you to believe that it has NOT parsed it.  

I was parsing output from hostip.info which uses XML as an output with
GML.

Here is an example of the XML I was working with when I cam a


Reproduce code:
---------------
---
>From manual page: book.simplexml
---
$ipAddr = "209.240.56.78";
$data = file_get_contents("http://api.hostip.info/?ip=".$ipAddr);

        $xml = @simplexml_load_string(str_replace(":", "_", $data)); 
//SimpleXML has issues parsing the ":", replacing it with underscore to
make this work.

        $city = $xml->gml_featureMember->Hostip->gml_name;
        $country = $xml->gml_featureMember->Hostip->countryName;
        $country_abbrev = $xml->gml_featureMember->Hostip->countryAbbrev;

        $lat_long =
$xml->gml_featureMember->Hostip->ipLocation->gml_PointProperty->gml_Point->gml_coordinates;

echo $city

Expected result:
----------------
This is what XML looks like coming from the site:
<HostipLookupResultSet version="1.0.0" xmlns="http://www.hostip.info/api";
xmlns:gml="http://www.opengis.net/gml";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.hostip.info/api/hostip-1.0.0.xsd";>
 <gml:description>This is the Hostip Lookup Service</gml:description>
 <gml:name>hostip</gml:name>
 <gml:boundedBy>
  <gml:Null>inapplicable</gml:Null>
 </gml:boundedBy>
 <gml:featureMember>
  <Hostip>
   <gml:name>(Unknown City?)</gml:name>
   <countryName>(Unknown Country?)</countryName>
   <countryAbbrev>XX</countryAbbrev>
   <!-- Co-ordinates are unavailable -->
  </Hostip>
 </gml:featureMember>
</HostipLookupResultSet>


Based on my echo of $city, I would expect to see:

Providence RI

Actual result:
--------------
Blank - nothing.  

SimpleXML will not throw an error if it runs into an issue parsing
anything with a ":" in the tag.



-- 
Edit bug report at http://bugs.php.net/?id=48049&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=48049&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=48049&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=48049&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=48049&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48049&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48049&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48049&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48049&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48049&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48049&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48049&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48049&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48049&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48049&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48049&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48049&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48049&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48049&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48049&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48049&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48049&r=mysqlcfg

Reply via email to