My XML Feed Choked

  • Thread starter Malcolm Dew-Jones
  • Start date
M

Malcolm Dew-Jones

Joe Cox ([email protected]) wrote:
: I am relatively new to XML. I built a website using XML to transfer query
: results to web browsers. Everything was working and I was doing final
: testing before deploying it, but ran into an XML problem.

: I got the following error:


: Whitespace is not allowed at this location. Error processing resource
: 'http://compass/cgi-bin/keyword_search.php'. Line 15...

: <name>CO & CO</name>
: ------------^


: 'CO & CO' is a string that represents the name of a company that was fed out
: of the database as part of a query result. My PHP code builds it into XML

(not quite)

: Apparently, XML doesn't like to see an '&' between it's tags. I though XML
: ignored everything between tags, so why does it snag on this?

No. Various things must be escaped, most obviously > by using &gt;

"&" itself must therefore also be escaped, by using &amp;

(To ensure no misunderstanding, the above escapes, with each character
quoted)

"&" "g" "t" ";"

"&" "a" "m" "p" ";"


Is there a
: simple fix to this or must I go back and write exception code to handle
: these?

When you generate the XML you must escape various things. I'm sure there
are XML libraries for PHP that make it easy to generate valid XML from
arbitrary input, but I don't know any names off hand.
 
J

Joe Cox

I am relatively new to XML. I built a website using XML to transfer query
results to web browsers. Everything was working and I was doing final
testing before deploying it, but ran into an XML problem.

I got the following error:


Whitespace is not allowed at this location. Error processing resource
'http://compass/cgi-bin/keyword_search.php'. Line 15...

<name>CO & CO</name>
------------^


'CO & CO' is a string that represents the name of a company that was fed out
of the database as part of a query result. My PHP code builds it into XML
Apparently, XML doesn't like to see an '&' between it's tags. I though XML
ignored everything between tags, so why does it snag on this? Is there a
simple fix to this or must I go back and write exception code to handle
these?

Any suggestion would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top