Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: My XML Feed Choked

From: yf110@----.--------.--.-- (------- ---------)
To: NULL
Date: 11/3/2005 2:16:00 PM
Joe Cox (jcox@k...) 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.




--

This programmer available for rent.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent