Jump to content

SimpleXML and htmlspecialchars?


digitus78

Recommended Posts

Hello and thanks in advance for any help.

 

Overview:

Im tyring to pull data from a XML api using simpleXML.  I have ran into a problem with special characters and entities that simpleXML does not accept.

IE " "  Ive tried all the solutions i could find to no avail.

 

SimpleXML gives me this error.

 

parser error : Entity 'nbsp' not defined in

 

Here is my code.

 

$feed = simplexml_load_file('URL TO API FEED');
$feed = html_entity_decode($feed);
$feed = str_ireplace(array('<','>','&','\'','"'),array('<','>','&',''','"'),$feed);

echo 'Game Title: ' .$feed->game. '</br>';
echo 'Ponts Earned: ' .$feed->gamerscore. '</br>';
echo 'Total Achievements: ' .$feed->totalachievements. '</br>';

foreach($feed->achievements->achievement as $ach) {

$output = htmlentities($feed->title, ENT_QUOTES, "UTF-8");
echo $output;
if( !empty($ach->unlockedartwork)){
echo '<img src=' .$ach->unlockedartwork. '></img></br>';
}else {
echo '<img src=' .$ach->artwork. '></img></br>';
}

}

 

Here is the code im trying to retrieve.

      <achievement id="40">
          <title>Have Gun Will Travel </title>
          <artwork>http://</artwork>
          <gamerscore>20</gamerscore>
          <unlocked>true</unlocked>
          <unlockdate>7/4/2010</unlockdate>
      </achievement>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.