Reputation: 160
When I'm trying to use simplexml_load_string
it returns an array of "SIMPLE XML objects" with some "Empty" object attributes. Actually those attributes are not empty in the real XML output!
Do you have any suggestions?
$url = "widgets.sportsevents365.com/data/tickets/v2.0/events/?q=cq,0,$sportType,$numOfDays&page=$page&perpage=$perpage";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER ,array('Contect-Type:text/xml','application/xml') );
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "*****:*****");
$result = curl_exec($ch);
curl_close($ch);
$xmldata = simplexml_load_string($result);
print_r( $xmldata );
Upvotes: 1
Views: 139
Reputation: 68556
im getting values inside
<![CDATA[
, then the simplexml_load_string is removig them, so how to catch those values ?
You need to use the LIBXML_NOCDATA
flag.
$xmldata = simplexml_load_string($result,LIBXML_NOCDATA);
LIBXML_NOCDATA
?By using this flag it will merge the CDATA
as text nodes.
Upvotes: 1