incoe
incoe

Reputation: 112

Warning: simplexml_load_file()

I have this code

<?php

$url = "_configurations/right_sidebar_links.xml";
$xml = simplexml_load_file($url);

foreach($xml->links as $links)
{
    echo "<li>";
    echo "<a href='".$links->url."'>";
    echo $links->name."</a></li>";
}

?>

that loads xml links from another file, it works fine with links that doesn't have any strange characters but when you enter long link with weird characters it gives an error that is saying

Warning: simplexml_load_file() [function.simplexml-load-file]: _configurations/right_sidebar_links.xml:17: parser error : EntityRef: expecting ';' in .../includes/loadLinks.php on line 8

any help would be much appreciated.

here is an example of the link

http://www.exampe.com/gp/product/B007RT6OZW/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B007RT6OZW&linkCode=as2&tag=backpaininfor-20

Thanks!

Upvotes: 0

Views: 11111

Answers (1)

Steve Robbins
Steve Robbins

Reputation: 13802

The contents of your XML file are invalid. Make sure it's properly encoded (ie & is &amp;) and/or CDATA tags are used where necessary.

If you open the XML file in a modern browser, they'll usually give you a detailed answer as to where the error is (line and character).

Also, see this hack

Upvotes: 1

Related Questions