473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 4249
Dormilich
8,658 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,658 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,658 Expert Mod 8TB
note: threads merged. please don't post the same topic twice.

MODERATOR
Feb 17 '10 #6
Dormilich
8,658 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

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

Similar topics

1
by: ash | last post by:
My input file is something like this <DB> <E> <TAG1><!]></TAG1> <TAG2><!]></TAG2> <TAG3><!]></TAG3> </E> <E> <TAG1><!]></TAG1>
9
by: Iain | last post by:
I want to create an XML configuration file which might look like <REGION Name="Europe" WingDing="Blue"> <COUNTRY Name="UK" WingDing="white"> <TOWN Name="London" WingDing="Orange" /> </COUNTRY>...
4
by: Pat | last post by:
Is anyone using XML instead of HTML for pages of content? If so is there a public site to browse? Can someone point me to a discussion of the pros and cons of doing this? I am trying to get a...
9
by: Stefan Franke | last post by:
Hi, I've got the following simple XSLT stylesheet, that lists all the values of the elements of any given XML file. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0"...
4
by: grghoward | last post by:
I am receiving a series of Microsoft Word documents from web clients that they upload to my server. I need to convert them to XML to pass through to another system. I have done this through...
0
by: canasdaq | last post by:
Can anyone please help me. I was looking at the article "http://www.eggheadcafe.com/articles/20030603.asp". I am new to .net and know nothing in c#. I want to write a menu in asp.net. Can anyone...
6
by: mandibdc | last post by:
I need to extract some elements from a very large XML file. Because of the size, I'd like to work with it on my Linux machine as a text file. Basically, I am going to have a list of specific...
9
by: gregmcmullinjr | last post by:
Hello, I am new to the concept of XSL and am looking for some assistance. Take the following XML document: <binder> <author>Greg</author> <notes> <time>11:45</time>
4
by: SandIsland | last post by:
I am trying to extract just a portion of data from an XML data source: <Row> <Col Name="Col0">123456<CellColour>36</CellColour> <FontColour>1</FontColour> <Bottom>1</Bottom>...
1
by: mark4asp | last post by:
Apologies, I just can't get my head around xslt but I need to do this. I have an xml file with two attributes per product. One of the attributes repeats to produce several groups (3 in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.