lukas
lukas

Reputation: 495

xml String with & inside

I have got a simple question, I have a xml string with an url inside, which contains the "ls="

<?xml version="1.0" encoding="utf-8"?>
   <resources>
      <string name="passOnText">iOS: https://itunes.apple.com/us/app/xyz/id123456?l=de&ls=1&mt=8 \nAndroid: http://play.google.com/store/apps/details?id=x.y.z</string>
   </resources>

now the xml validator tells me that:

The reference to entity "ls" must end with the ';' delimiter.

how can I workaroud this problem?

thanks in advance

lukas


edited title from "xml String with ls= inside" to "xml String with & inside"

Upvotes: 2

Views: 125

Answers (2)

Jaky71
Jaky71

Reputation: 162

If you want to give a link you should use a href in your string values.

Here is your working code:

<string name="passOnText">iOS: <a href="https://itunes.apple.com/us/app/xyz/id123456?l=de&ls=1&mt=8"> Click Here for iOS </a></string>
<string name="passOnText2">Android: <a href="http://play.google.com/store/apps/details?id=x.y.z> Click Here for Android </a></string>

Upvotes: 0

laalto
laalto

Reputation: 152787

& is a special character in XML that starts an entity reference. The XML parser then goes looking for the terminating ; of the entity reference and doesn't find one.

To produce & itself, write &amp; in the XML. (It's an entity reference, amp short for "ampersand".)

Upvotes: 2

Related Questions