Jump to content

SimpleXML and colons?


cat3

Recommended Posts

Hey there!

 

I'm working on an application that uses the White Pages API, which returns all queried data in XML. I'm trying to use SimpleXML to read the query status code, which is returned in the second line of the code below ("wp:code="No Data Found""). I want my application to do different things based on the code returned (ie; "No Data Found" = show error, "Data Found" = show listing, etc.), but I'm having trouble reading this part of the XML... I'm trying to use $simplexml->wp:wp->wp:result->attributes(); but the colons keep getting in the way and I get an error:

 

Parse error: syntax error, unexpected ':' in /home/******/public_html/******/inc/xml.php on line 9.

 

Any ideas?

 

<wp:wp>
<wp:result wp:type="success" wp:message="The search did not find results" wp:code="No Data Found"/>
−
<wp:meta>
<wp:linkexpiration>2008-04-11</wp:linkexpiration>
<wp:recordrange wp:lastrecord="0" wp:firstrecord="0" wp:totalavailable="0"/>
<wp:apiversion>1.0</wp:apiversion>
−
<wp:searchlinks>
<wp:link wp:linktext="Whitepages.com" wp:type="homepage">http://www.whitepages.com/*****/</wp:link>
−
<wp:link wp:linktext="Link to this api call" wp:type="self">
http://api.whitepages.com/reverse_phone/1.0/?phone=**********;api_key=*****************************
</wp:link>
</wp:searchlinks>
</wp:meta>
</wp:wp>

Link to comment
https://forums.phpfreaks.com/topic/99832-simplexml-and-colons/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.