0

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!

MTM
  • 919
  • 10
  • 22
incoe
  • 112
  • 1
  • 2
  • 12
  • Specify _weird characters_ .. , and a portion of the XML with the _weird characters_, somewhere around and about the lines the error is pointing to. – dbf Sep 13 '12 at 17:27
  • here is an example link http://www.example.com/gp/product/B007RT6OZW/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B007RT6OZW&linkCode=as2&tag=backpaininfor-20 – incoe Sep 13 '12 at 17:31

1 Answers1

1

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

Community
  • 1
  • 1
Steve Robbins
  • 13,672
  • 12
  • 76
  • 124