> scala> val title = "Catsby & Twisp"

+1 for the Penny Arcade reference.

On Mar 16, 8:51 am, Derek Chen-Becker <[email protected]> wrote:
> Well, it may be that the XML output portion of Scala is escaping your
> ampersands a second time. For instance, check out this session in the
> interpreter:
>
> scala> val title = "Catsby &amp; Twisp"
> title: java.lang.String = Catsby &amp; Twisp
>
> scala> val escaped = <span>{title}</span>
> escaped: scala.xml.Elem = <span>Catsby &amp;amp; Twisp</span>
>
> scala> val unescaped = <span>{ scala.xml.Unparsed(title) }</span>
> unescaped: scala.xml.Elem = <span>Catsby &amp; Twisp</span>
>
> Note that if you embed a String within XML elements, Scala will
> automatically escape any ampersands unless you wrap the String in a
> scala.xml.Unparsed instance. The second test there will render in the
> browser like "Catsby &amp; Twisp", because the ampersand was escaped. I know
> you're asking about the Utility object, but I think that would be fixing the
> symptom rather than the cause.
>
> Derek
>
> On Mon, Mar 16, 2009 at 6:13 AM, Jeremy Mawson <[email protected]
>
> > wrote:
> > Hi,
>
> > I've been mucking around with lift and having a great time. I have cooked
> > up a page that retrieves XML from a datasource and renders it. However some
> > of the text elements I extract are HTML encoded. When rendered in the
> > browser it looks like HTML code, rather than rendered HTML.
>
> > I looked for a scala utility to unescape this, found
> > scala.xml.Utility.unescape, but could not get it working.
>
> > Here's how I've tried to use it.
>
> >       val title = Utility.unescape(result \ "title" text, new
> > StringBuilder)
>
> > Unfortunately this always gives me a value of null, even though
> > result.\("title").text is something like - "Tsvangirai&amp;#39;s wife killed
> > in&lt;b&gt;car&lt;/b&gt;crash - ABC News"
>
> > What could I be doing wrong? I realise this is probably a plain old scala
> > question, but I hope someone here can help me anyway.
>
> > Thanks
> > Jeremy
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to