xml - convert & to & in xslt -


i have variable containing xml value

<xsl:variable name="resp"> <table>  <news_id>39</news_id>  <news_title>strada &#8211; tso</news_title>  <news_content>extending support ifa&#8217;s family in form of income security paying last drawn trail paid ifa before demise.</news_content>  <news_type>1</news_type>  <doc_url>upload/docs/12345.pdf</doc_url>  <doc_size>185859</doc_size>  <news_date>2014-09-19 12:54:11.0</news_date>  <is_enabled>1</is_enabled> </table>   <xsl:variable> 

how parse values in variable. please help.

i have structure, this:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"     xmlns:xs="http://www.w3.org/2001/xmlschema"     exclude-result-prefixes="xs"     version="1.0">     <xsl:output indent="yes"/>     <xsl:template match="/">         <xsl:variable name="resp">             <table>                 <news_id>39</news_id>                 <news_title>strada &#8211; tso</news_title>                 <news_content>extending support ifa&#8217;s family in form of income security paying last drawn trail paid ifa before demise.</news_content>                 <news_type>1</news_type>                 <doc_url>upload/docs/12345.pdf</doc_url>                 <doc_size>185859</doc_size>                 <news_date>2014-09-19 12:54:11.0</news_date>                 <is_enabled>1</is_enabled>             </table>           </xsl:variable>          <!-- using copy-of structure of xml -->         <xsl:copy-of select="$resp" />     </xsl:template> </xsl:stylesheet> 

if want text inside variable, this:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"     xmlns:xs="http://www.w3.org/2001/xmlschema"     exclude-result-prefixes="xs"     version="1.0">     <xsl:output indent="yes"/>     <xsl:template match="/">         <xsl:variable name="resp">             <table>                 <news_id>39</news_id>                 <news_title>strada &#8211; tso</news_title>                 <news_content>extending support ifa&#8217;s family in form of income security paying last drawn trail paid ifa before demise.</news_content>                 <news_type>1</news_type>                 <doc_url>upload/docs/12345.pdf</doc_url>                 <doc_size>185859</doc_size>                 <news_date>2014-09-19 12:54:11.0</news_date>                 <is_enabled>1</is_enabled>             </table>           </xsl:variable>         <variable>         <!-- using value-of values of xml inserting variable element -->             <xsl:value-of select="$resp"/>         </variable>       </xsl:template> </xsl:stylesheet> 

if want different values elements inside variable this:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"     xmlns:xs="http://www.w3.org/2001/xmlschema"     exclude-result-prefixes="xs"     version="1.0">     <xsl:output indent="yes"/>     <xsl:template match="/">         <xsl:variable name="resp">             <table>                 <news_id>39</news_id>                 <news_title>strada &#8211; tso</news_title>                 <news_content>extending support ifa&#8217;s family in form of income security paying last drawn trail paid ifa before demise.</news_content>                 <news_type>1</news_type>                 <doc_url>upload/docs/12345.pdf</doc_url>                 <doc_size>185859</doc_size>                 <news_date>2014-09-19 12:54:11.0</news_date>                 <is_enabled>1</is_enabled>             </table>           </xsl:variable>          <!-- if want value of news_id inside variable -->         <newsid>             <xsl:value-of select="$resp/table/news_id"/>         </newsid>          <!-- below shorter xpath-syntax -->         <newstitle>             <xsl:value-of select="$resp//news_title"/>         </newstitle>      </xsl:template> </xsl:stylesheet> 

hope helps.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -