Jump to content

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

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.