Welcome to WebmasterWorld Guest from 34.239.158.107

Forum Moderators: open

Message Too Old, No Replies

XML Illegal Character Help

Can this be fixed?

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

Junior Member

10+ Year Member

joined:Sept 24, 2007
posts: 51
votes: 0


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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 7, 2004
posts:933
votes: 0


Change & to &

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

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

Junior Member

10+ Year Member

joined:Sept 24, 2007
posts: 51
votes: 0


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

Senior Member from CA 

WebmasterWorld Senior Member httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4061
votes: 0


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;

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

Senior Member from CA 

WebmasterWorld Senior Member httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4061
votes: 0


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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members