2

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"

lukas
  • 495
  • 4
  • 13
  • 3
    are you sure the problem is ls= and not & ? Can you replace & with & and see if it keeps to complain? – Blackbelt Jul 18 '14 at 07:53
  • Possible duplicate of [The reference to entity "foo" must end with the ';' delimiter](http://stackoverflow.com/questions/6483807/the-reference-to-entity-foo-must-end-with-the-delimiter) – BalusC May 09 '16 at 12:24

2 Answers2

2

& 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".)

laalto
  • 150,114
  • 66
  • 286
  • 303
0

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>
Jaky71
  • 162
  • 1
  • 9
  • thank you really much for this additional information! I diden't know that this is possible! thank you – lukas Jul 18 '14 at 08:11
  • In XML, & needs to be escaped in attributes as well as in elements. So this does not solve the problem. – Michael Kay Jul 18 '14 at 11:00
  • I tried his code and correct it by this codes. This works and I said "If you want to give a link you should use a href in your string values." then share this code. I didnt claim that I solved "&" problem – Jaky71 Jul 18 '14 at 11:04