Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

XmlFile Containing the & Character in text

XmlFile Containing the & Character in text

XmlFile Containing the & Character in text

Just a query about the & character in an xml file

Say Text = Me & my dog?

I run it through a UTF-8 conversion and i get

Me & My Dog?

I am planning using this file for a game on the internet

?? will i have any problems with the &

Appreciate any advice

Regards Robert

RE: XmlFile Containing the & Character in text


A UTF-8 converter should not transform & into anything else and just leave it as it is.

The string Me & my dog? must be encoded in XML as Me &amp; my dog? or, if (part of) a text node inside an element, as <![CDATA[Me & my dog?]]>

RE: XmlFile Containing the & Character in text

Thanks for your advice.. much appreciated.

Just double confirming

Yes the original is <Me & my Dog?> ie its is within <>

do i have to make it <Me &amp;amp; My Dog?>
or <![CDATA[Me & my dog?]]>

if i leave it as <Me &amp;amp; My Dog?> it seems to load into a browser ok

I am pretty new to xml hope i do not sound too vague !!@@!

Regards Robert

RE: XmlFile Containing the & Character in text


You mean within ><, right?

If you encode your text as Me &amp;amp; my dog?, the system that will read your XML data will interpret it as Me &amp; my dog?, while if you encode as Me &amp; my dog? the document contents will be read as Me & my dog?, which is what you intend.

The reason why & must be encoded as &amp; is because it signals an escape sequence that textually represents (among others) the characters that serve some purpose in XML: <>'" and & itself (as a consequence of its role).

RE: XmlFile Containing the & Character in text


Thanks for your help...much appreciated

Regards Robert

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close