simplexml_load_file parser error with ampersands in urls

[email protected] (Dennis Nezic)
Newsgroups php.general
Message-ID <[email protected]>
If there are ampersands (&) in links within tags (eg. href= url=
rel=) simplexml_load_file() fails with

  parser error : EntityRef: expecting ';'

This useful comment in the manual suggests str_replace()'ing it with
the &amp; entity:

  https://www.php.net/manual/en/function.simplexml-load-file.php#117566

%26 url encoding also works, although no other character that
I'm aware of seems to cause this parser error / requires
urlencode()'ing.

But this seems like a bug, or something that simplexml_load_file should
be able to handle? Or does xml or something not allow &'s in tag
properties?

For example, trying to load this file:

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <entry>
    <link href="http://example.com/bla.php?yes&no" />
  </entry>
</feed>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.