How to unencode escaped XML with xQuery

Posted by mbrevoort on Stack Overflow See other posts from Stack Overflow or by mbrevoort
Published on 2010-04-09T22:54:12Z Indexed on 2010/04/10 1:13 UTC
Read the original article Hit count: 431

Filed under:
|
|

I have a variable in xQuery of type xs:string with the value of an encoded HTML snippet (the content of a twitter tweet). It looks like this:

Headlines-Today • AP sources: <b>Obama</b> pick for Justice post withdraws : News - Rest Of World - <a href="http://shar.es/mqMAG">http://shar.es/mqMAG</a>

When I try to write this out in an HTML block, I need the string to be unescaped so that the HTML snippet will be interpreted by the browser. Instead the string is getting written out as is and the browser is rendering it as just text (so you see <a href="blah.... ). Here's how I'm writing out this string:

{$entry/atom:content/text()}

How can I have the escaped characters unencoded so it writes < rather tha &lt; ?

I've tried to do a replacelike this but it always replaces the &lt; with &lt; !

fn:replace($s, "&lt;", "<")

© Stack Overflow or respective owner

Related posts about xquery

Related posts about marklogic