469,271 Members | 1,776 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

How to extract xml from rssfeed using xslt

16
I have given rss.xml as input

below is the rsscode .


Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?> 
  2.  
  3. <?xsl-stylesheet type="text/xsl" href="http://192.168.0.128/testrss/test/mytest.xsl"?> 
  4.  
  5.  <rss version="2.0">
  6.  <channel>
  7. <!--
  8.   Hey!
  9.   This web page is actually a data file that is meant to be
  10.    read by RSS reader programs.
  11.   See http://interglacial.com/rss/about.html to learn
  12.    more about RSS.
  13.  
  14.   This data file is meant to be read by RSS reader programs.
  15.   See http://interglacial.com/rss/about.html to learn more about RSS.
  16.  
  17. -->
  18.  
  19.  
  20.   <title>wholesale</title> 
  21.  
  22.   <link>http://localhost/fusionchart/rssfeed1.aspx</link> 
  23.  
  24.   <description>The latest whole sale report</description> 
  25.  
  26.   <copyright>Copyright 2001 - 2009 Roxy Palace Casino</copyright> 
  27.  
  28.   <language>en-us</language> 
  29.   <guid>http://localhost/fusionchart/rssfeed12.aspx</guid> 
  30.   <url>http://localhost/fusionchart/rssfeed12.aspx</url> 
  31.   <title>wholesale</title> 
  32.   <link>http://localhost/fusionchart/rssfeed12.aspx</link> 
  33.   <description>This shows up in title of link</description> 
  34.  <item>
  35.   <title>XTPNR : 122.0000</title> 
  36.   <description>122.0000</description> 
  37.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  38.   </item>
  39.  <item>
  40.   <title>XTPR0 : 1011.0000</title> 
  41.   <description>1011.0000</description> 
  42.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  43.   </item>
  44.  <item>
  45.   <title>XTPNR1 : 85.0000</title> 
  46.   <description>85.0000</description> 
  47.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  48.   </item>
  49.  <item>
  50.   <title>XXABK5 : 45.0000</title> 
  51.   <description>45.0000</description> 
  52.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  53.   </item>
  54.  <item>
  55.   <title>XXABK6 : 86.0000</title> 
  56.   <description>86.0000</description> 
  57.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  58.   </item>
  59.  <item>
  60.   <title>XXABK2 : 5.0000</title> 
  61.   <description>5.0000</description> 
  62.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  63.   </item>
  64.  <item>
  65.   <title>XXABK20 : 56.0000</title> 
  66.   <description>56.0000</description> 
  67.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  68.   </item>
  69.  <item>
  70.   <title>XXABK4 : 56.0000</title> 
  71.   <description>56.0000</description> 
  72.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  73.   </item>
  74.  <item>
  75.   <title>XTPNR7 : 78.0000</title> 
  76.   <description>78.0000</description> 
  77.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  78.   </item>
  79.  <item>
  80.   <title>XTPNR8 : 3.0000</title> 
  81.   <description>3.0000</description> 
  82.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  83.   </item>
  84.  <item>
  85.   <title>XTPNR9 : 56.0000</title> 
  86.   <description>56.0000</description> 
  87.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  88.   </item>
  89.  <item>
  90.   <title>XTPNR2 : 78.0000</title> 
  91.   <description>78.0000</description> 
  92.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  93.   </item>
  94.  <item>
  95.   <title>XTPNR3 : 28.0000</title> 
  96.   <description>28.0000</description> 
  97.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  98.   </item>
  99.  <item>
  100.   <title>XTPNR4 : 78.0000</title> 
  101.   <description>78.0000</description> 
  102.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  103.   </item>
  104.  <item>
  105.   <title>XTPNR5 : 66.0000</title> 
  106.   <description>66.0000</description> 
  107.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  108.   </item>
  109.  <item>
  110.   <title>XTPNR6 : 98.0000</title> 
  111.   <description>98.0000</description> 
  112.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  113.   </item>
  114.  <item>
  115.   <title>XXABK3 : 87.0000</title> 
  116.   <description>87.0000</description> 
  117.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  118.   </item>
  119.  <item>
  120.   <title>XXABK7 : 56.0000</title> 
  121.   <description>56.0000</description> 
  122.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  123.   </item>
  124.  <item>
  125.   <title>XXABK8 : 567.0000</title> 
  126.   <description>567.0000</description> 
  127.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  128.   </item>
  129.  <item>
  130.   <title>XXABK9 : 455.0000</title> 
  131.   <description>455.0000</description> 
  132.   <link>http://192.168.0.131/fusionchart/Default.aspx</link> 
  133.   </item>
  134.   </channel>
  135.   </rss>


I also have done xslt for it


below is xsl



Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
  3.  <xsl:output method="xml" type="text/xsl" />
  4.  <xsl:template match="/rss/channel">
  5. <!--   <xsl:for-each select="rss/channel"> -->
  6.  
  7.     <title>
  8.      <xsl:copy-of select="title/node()"/>
  9.      <!--layer=Default-->
  10.     </title>
  11.     <description>
  12.      <xsl:copy-of select="description/node()"/>
  13.      <!--layer=Default-->
  14.     </description>
  15.     <xsl:for-each select="item">
  16.     <item>
  17.     <title>   
  18.     <xsl:copy-of select="title/node()"/>
  19. <new></new>
  20.     </title>
  21.     <description>
  22.  
  23.     <xsl:copy-of select="description/node()"/>
  24.  
  25.     </description>
  26.  
  27.      </item>
  28.     </xsl:for-each>
  29.  
  30.      <!--layer=Default-->
  31.  
  32.    <!--   </xsl:for-each>
  33.  -->  <!--layer=Default-->
  34.  </xsl:template>
  35. </xsl:stylesheet>

Output required shown below



Expand|Select|Wrap|Line Numbers
  1. <channel>
  2.   <title>wholesale</title> 
  3.   <description>The latest whole sale report</description> 
  4. <item>
  5.  <title>XTPNR </title> 
  6.  <description>122.0000</description> 
  7. </item>
  8. <item>
  9.  <title>XTPNR0 </title> 
  10.  <description>1011.0000</description> 
  11. </item>
  12. <item>
  13.  <title>XTPNR1</title> 
  14.  <description>85.0000</description> 
  15. </item>
  16. <item>
  17.  <title>XTPNR1</title> 
  18.  <description>85.0000</description> 
  19. </item>
  20. <item>
  21.  <title>XXABK5</title> 
  22.  <description>45.0000</description> 
  23. </item>
  24. <item>
  25.  <title>XXABK6</title> 
  26.  <description>86.0000</description> 
  27. </item>
  28. <item>
  29.  <title>XXABK2 </title> 
  30.  <description>5.0000</description> 
  31. </item>
  32. <item>
  33.  <title>XXABK20 </title> 
  34.  <description>56.0000</description> 
  35. </item>
  36. <item>
  37.  <title>XXABK4 </title> 
  38.  <description>56.0000</description> 
  39. </item>
  40. <item>
  41.  <title>XTPNR7 </title> 
  42.  <description>78.0000</description> 
  43. </item>
  44. <item>
  45.  <title>XTPNR8 </title> 
  46.  <description>3.0000</description> 
  47. </item>
  48. <item>
  49.  <title>XTPNR9 </title> 
  50.  <description>56.0000</description> 
  51. </item>
  52. <item>
  53.  <title>XTPNR2 </title> 
  54.  <description>78.0000</description> 
  55. </item>
  56. <item>
  57.  <title>XTPNR3 </title> 
  58.  <description> 28.0000</description> 
  59. </item>
  60. <item>
  61.  <title>XTPNR4  </title> 
  62.  <description> 78.0000</description> 
  63. </item>
  64. <item>
  65.  <title>XTPNR5  </title> 
  66.  <description> 66.0000</description> 
  67. </item>
  68. <item>
  69.  <title>XTPNR6 </title> 
  70.  <description> 98.0000</description> 
  71. </item>
  72. <item>
  73.  <title>XXABK3 </title> 
  74.  <description> 87.0000</description> 
  75. </item>
  76. <item>
  77.  <title>XXABK7 </title> 
  78.  <description>56.0000</description> 
  79. </item>
  80. <item>
  81.  <title>XXABK8</title> 
  82.  <description>567.0000</description> 
  83. </item>
  84. <item>
  85.  <title>XXABK9</title> 
  86.  <description>455.0000</description> 
  87. </item>
  88. </channel>


Here i am getting xml output in an xsl-editor

but in browser rss feed is displayed


can anyone help me ?
Feb 15 '10 #1
6 4134
Dormilich
8,651 Expert Mod 8TB
of course, thatís what it is, a feed (in XML format)
Feb 15 '10 #2
sisu
16
can anyone help me to get xml from rss feed using xslt
Feb 16 '10 #3
Dormilich
8,651 Expert Mod 8TB
RSS is already XML, unless you tell me, what kind of XML you want (and what’s the difference to your previous thread) I don’t see a possibility to help you.
Feb 16 '10 #4
sisu
16
i want display only item tag and descripton tag in output
Feb 16 '10 #5
Dormilich
8,651 Expert Mod 8TB
note: threads merged. please don't post the same topic twice.

MODERATOR
Feb 17 '10 #6
Dormilich
8,651 Expert Mod 8TB
it’s not perfect, but it’s a start.
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
  3. <!-- note that I removed the type attribute, kept throwing errors -->
  4. <xsl:output method="xml" />
  5.  
  6. <xsl:template match="/">
  7. <channel>
  8.   <xsl:copy-of select="/rss/channel/title"/>
  9.   <xsl:copy-of select="/rss/channel/description"/>
  10.   <xsl:apply-templates/>
  11. </channel>
  12. </xsl:template>
  13.  
  14. <xsl:template match="item">
  15.   <xsl:copy>
  16.     <xsl:copy-of select="title"/>
  17.     <xsl:copy-of select="description"/>
  18.   </xsl:copy>
  19. </xsl:template>
  20.  
  21. </xsl:stylesheet>
Feb 17 '10 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by ash | last post: by
9 posts views Thread by Stefan Franke | last post: by
reply views Thread by canasdaq | last post: by
9 posts views Thread by gregmcmullinjr | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.