I am trying to transform some xml, which was returned by the Twitter Search api. It looks like the content element contains text that is escaped twice, Inception style. When I use the following in my XSL stylesheet it only unescapes it once:
<xsl:value-of select="atom:content" disable-output-escaping="yes" />
How do I perform the second round of unescaping? Thanks!
Example input document:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:google="http://base.google.com/ns/1.0" xml:lang="en-US" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom" xmlns:twitter="http://api.twitter.com/">
<id>tag:search.twitter.com,2005:search/from:myusername</id>
<link type="text/html" href="http://search.twitter.com/search?q=from%3Amyusername" rel="alternate"/>
<link type="application/atom+xml" href="http://search.twitter.com/search.atom?q=from%3Amyusername" rel="self"/>
<title>from:myusername - Twitter Search</title>
<link type="application/opensearchdescription+xml" href="http://search.twitter.com/opensearch.xml" rel="search"/>
<link type="application/atom+xml" href="http://search.twitter.com/search.atom?q=from%3Amyusername&since_id=21346924004" rel="refresh"/>
<updated>2010-08-16T21:38:42Z</updated>
<openSearch:itemsPerPage>15</openSearch:itemsPerPage>
<entry>
<id>tag:search.twitter.com,2005:21346924004</id>
<published>2010-08-16T21:38:42Z</published>
<link type="text/html" href="http://twitter.com/myusername/statuses/21346924004" rel="alternate"/>
<title>testing special chars for a custom twitter client < > & ' £ €</title>
<content type="html">testing special chars for a custom twitter client &lt; &gt; &amp; &apos; £ €</content>
<updated>2010-08-16T21:38:42Z</updated>
<link type="image/png" href="http://a1.twimg.com/profile_images/820967365/twitter_avatar_normal.jpg" rel="image"/>
<twitter:geo>
</twitter:geo>
<twitter:metadata>
<twitter:result_type>recent</twitter:result_type>
</twitter:metadata>
<twitter:source><a href="http://twitter.com/">web</a></twitter:source>
<twitter:lang>en</twitter:lang>
<author>
<name>myusername</name>
<uri>http://twitter.com/myusername</uri>
</author>
</entry>
</feed>
This stylesheet:
Output:
Note: The text node of
atom:content
is now unescape, but this is not well formedEdit: Just in case you need a well formed output, you could add this output declaration:
Then you could strip the
disable-output-escaping="yes"
, so your output will be:Note: There is no escape perform on CDATA sections.