Forum Moderators: open

Message Too Old, No Replies

XML Illegal Character Help

Can this be fixed?

         

DannyTweb

10:24 pm on Nov 15, 2007 (gmt 0)

10+ Year Member



I have a line of code in my xml page pointing to site that has what my browser says are illegal characters. Is there any way to reformat this?

http://www.example.com/index.jsp?pageName=hotInfo&cid=27477&temp1=BBS&hotelID=5595

Thank you

tomda

11:33 pm on Nov 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Change & to &

[URL]?pageName=hotInfo&cid=27477&[etc...]

DannyTweb

11:45 pm on Nov 15, 2007 (gmt 0)

10+ Year Member



Thank you

httpwebwitch

2:16 pm on Nov 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



another way is to declare that section as CDATA.

CDATA is "Character Data", and is essentially freeform data that needn't conform to XML syntax. Everything inside a CDATA section is ignored by the parser.


<url><![CDATA[http://www.example.com/index.jsp?pageName=hotInfo&cid=27477&temp1=BBS&hotelID=5595]]></url>

is the same as


<url>http://www.example.com/index.jsp?pageName=hotInfo&amp;cid=27477&amp;temp1=BBS&amp;hotelID=5595</url>

If your data contains a lot of "&" and "<" characters, or if the data is fed in from an external source, it's usually easier to wrap it in a CDATA block instead of running it through a string replacement function.

CDATA also comes to the rescue when your data contains other non-entities like &nbsp; and &quot;

httpwebwitch

5:48 pm on Nov 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



correction

I said the one example was "the same as" the other. of course they're not the same; they validate differently.

the similarity is that they accomplish the same thing and solve the same problem.

it's a good habit to use CDATA sections for user-entered data, javascripts, text content. When the well-formedness + validity of something is uncertain and/or unnecessary.

CDATA is your prophelactic against user-transmitted invalid entities.