views:

97

answers:

2

I had a problem with:

 <iframe id="iframe1" src='http://stockcharts.com/h-sc/ui?s=MT&amp;p=D&amp;yr=2&amp;mn=0&amp;dy=0&amp;id=p43321191731' width="300px" height="300px"></iframe>

in Lift web framework (Scala) version. I get:

Message: java.util.NoSuchElementException
scala.RandomAccessSeq$$anon$13.next(RandomAccessSeq.scala:165)
scala.xml.parsing.MarkupParser$class.normalizeAttributeValue(MarkupParser.scala:1191)

It turned out the question mark ? in the iframe src attribute that caused this. What can I do to fix this quickly?

+4  A: 

http://www.mail-archive.com/[email protected]/msg08961.html

The problem is the ampersand, need to escape it

<iframe id="iframe1" src='http://stockcharts.com/h-sc/ui?s=MT&amp;amp;p=D&amp;amp;yr=2&amp;amp;mn=0&amp;amp;dy=0&amp;amp;id=p43321191731' widt    h="300px" height="300px"></iframe>
portoalet
+3  A: 

Escape the '&' characters.

scala> <elem attr="a&amp;"/>
res0: scala.xml.Elem = <elem attr="a&amp;"></elem>

Or:

scala> val a = "a&"
a: java.lang.String = a&

scala> <elem attr={a}/>
res1: scala.xml.Elem = <elem attr="a&amp;"></elem>
retronym