views:

153

answers:

1

Hi, I'm using the following code with cURL:

function _getStatsDataXMLString($url) {

    $curl = curl_init();

    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)');

    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($curl, CURLOPT_URL, $url);

    $xmlstr = curl_exec($curl);

    curl_close($curl);

    return $xmlstr;

}

The site I am trying to grab from is: http://xml.heroesofnewerth.com/xml_requester.php?f=player_stats&opt=nick&nick[]=yanagafol

Whenever I try to request data with the above function, the string it generates is: yanagafol173957844341541169317315000150000.009142347141111962425534613119823402602572171277264755751031151494960762160734306050303782332556000164255279111749522139194314968322760755616358407012000000011

I get the same printout with print_r

It is spaced out properly, but doesn't have any of the xml tag information so I can't convert it into an object for use with my database.

Any help would be greatly appreciated.

A: 

Try using htmlspecialchars to encode special characters in the string so that they print out as literals:

$xmlstr = htmlspecialchars(curl_exec($curl));

The inverse is htmlspecialchars_decode and htmlentities gives you more control over what gets encoded.

Rob Heiser