Jump to content

Escaping colons?


Popple3

Recommended Posts

I'm parsing XML, but many of the tags in the XML file (which I have no control over) have colons ( : ) in them, and as a result i get an "Unexpected ':'" parse error. Is there a way of escaping these colons, or removing them from the XML before it is parsed? I'm using PHP4...

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/82945-escaping-colons/
Share on other sites

Yeah, I meant to actually include it  ::)

 

<?php
include('xmlparser.php');
//Get the XML document loaded into a variable
$xml = file_get_contents('http://picasaweb.google.com/data/feed/api/user/popple3?kind=album');
//Set up the parser object
$parser = new XMLParser($xml);

//Work the magic...
$parser->Parse();

//Echo the plot of each <movie>
foreach($parser->document->entry as $entry)
{
    $imgurl = $entry->media:group->media:thumbnail->tagAttrs['url'];
    echo $entry->title[0]->tagData;
    echo "<img src=\"" . $imgurl . "\">";
}
?>

 

And then that just returns:

Parse error: parse error, unexpected ':' in /home/www/popple3.com/picasa.php on line 14

Link to comment
https://forums.phpfreaks.com/topic/82945-escaping-colons/#findComment-421870
Share on other sites

I recommend echoing out the parsed data to see what it contains. Use var_dump() or print_r().

 

Also, provide a link to the xml class you are using so that someone could duplicate the problem and look into it.

 

I suspect that media:group becomes media->group or 'media:group'. But echoing out the data would provide the definitive answer.

Link to comment
https://forums.phpfreaks.com/topic/82945-escaping-colons/#findComment-422053
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.