<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'filtering xml' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'filtering xml' posted on the 'XML Development' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 13:30:00 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 13:30:00 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>filtering xml</title>
      <link>http://www.programmersheaven.com/mb/xml/219410/219410/filtering-xml/</link>
      <description>Hi&lt;br /&gt;
&lt;br /&gt;
I have a problem with filtering my xml file.&lt;br /&gt;
&lt;br /&gt;
I have created an xml data file containing information about products for a music store (eg. cd's). The xml works fine and is displaying fine. I'm a little confused as to how to filter the xml so that only the CD's that I want displayed are displayed. Does anybody know how to do this?&lt;br /&gt;
Please help!!&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/xml/219410/219410/filtering-xml/</guid>
      <pubDate>Tue, 21 Oct 2003 18:02:20 -0700</pubDate>
      <category>XML Development</category>
    </item>
    <item>
      <title>Re: filtering xml</title>
      <link>http://www.programmersheaven.com/mb/xml/219410/220226/re-filtering-xml/#220226</link>
      <description>A you haven't specified exactly the way you want your data displayed, I assume you haven't tried XSL (Extensible Stylesheet Language) yet. XSL lets you transform the data structure in xml to a new one without changing the xml itself. In other terms, it means, you can sort or filter data in it.&lt;br /&gt;
&lt;br /&gt;
XSL is itself an xml file in as it must be well formed. It must contain well-formed HTML (xhtml) too. Just a portion of how your conditional formattong would look like.&lt;br /&gt;
&lt;br /&gt;
You must refer to this stylesheet in the XML file just after the first line (xml declaration)&lt;br /&gt;
&amp;lt;?xml-stylesheet type="text/xsl" href="cd.xsl"?&amp;gt;&lt;br /&gt;
&amp;lt;cds&amp;gt;&lt;br /&gt;
 &amp;lt;cd&amp;gt;&lt;br /&gt;
  &amp;lt;title&amp;gt;Title 1&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;artist&amp;gt;Artist 1&amp;lt;/artist&amp;gt;&lt;br /&gt;
  &amp;lt;price&amp;gt;12.99&amp;lt;/price&amp;gt;&lt;br /&gt;
 &amp;lt;/cd&amp;gt;&lt;br /&gt;
 &amp;lt;cd&amp;gt;&lt;br /&gt;
  &amp;lt;title&amp;gt;Title 2&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;artist&amp;gt;Artist 2&amp;lt;/artist&amp;gt;&lt;br /&gt;
  &amp;lt;price&amp;gt;13.99&amp;lt;/price&amp;gt;&lt;br /&gt;
 &amp;lt;/cd&amp;gt;&lt;br /&gt;
 &amp;lt;cd&amp;gt;&lt;br /&gt;
  &amp;lt;title&amp;gt;Title 3&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;artist&amp;gt;Artist 3&amp;lt;/artist&amp;gt;&lt;br /&gt;
  &amp;lt;price&amp;gt;9.99&amp;lt;/price&amp;gt;&lt;br /&gt;
 &amp;lt;/cd&amp;gt;&lt;br /&gt;
&amp;lt;/cds&amp;gt;&lt;br /&gt;
&lt;br /&gt;
cd.xsl might look like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;&lt;br /&gt;
&amp;lt;xsl:template match="/"&amp;gt;&lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Sample XSL Stylesheet&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt;&lt;br /&gt;
 &amp;lt;table&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;Title&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;Artist&amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:for-each select="catalog/cd"&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:if test="price &amp;amp;gt; 10"&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;xsl:value-of select="title"/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;xsl:value-of select="artist"/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's just an example, you have to tailor it to your needs. You can find great tutorials on the net, eg. &lt;a href="http://www.w3schools.com"&gt;http://www.w3schools.com&lt;/a&gt; on XML and XSL.&lt;br /&gt;
&lt;br /&gt;
: Hi&lt;br /&gt;
: &lt;br /&gt;
: I have a problem with filtering my xml file.&lt;br /&gt;
: &lt;br /&gt;
: I have created an xml data file containing information about products for a music store (eg. cd's). The xml works fine and is displaying fine. I'm a little confused as to how to filter the xml so that only the CD's that I want displayed are displayed. Does anybody know how to do this?&lt;br /&gt;
: Please help!!&lt;br /&gt;
: &lt;br /&gt;
: Thanks&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;&lt;span style="color: Grey;"&gt;To err is human, but to really foul things up requires a computer. (Farmers Almanac)&lt;/span&gt; &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/xml/219410/220226/re-filtering-xml/#220226</guid>
      <pubDate>Sun, 26 Oct 2003 13:12:55 -0700</pubDate>
      <category>XML Development</category>
    </item>
    <item>
      <title>Re: filtering xml</title>
      <link>http://www.programmersheaven.com/mb/xml/219410/220274/re-filtering-xml/#220274</link>
      <description>Hi &lt;br /&gt;
Thanks for your reply. I forgot to say I am actually using xsl to display the xml. I have the xml and xsl working together fine but i wasn't sure how to manipulate the xsl and xml together to filter the products that I wanted.&lt;br /&gt;
But, I have gone down an alternative path, so thanks anyway.&lt;br /&gt;
&lt;br /&gt;
dodge&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: A you haven't specified exactly the way you want your data displayed, I assume you haven't tried XSL (Extensible Stylesheet Language) yet. XSL lets you transform the data structure in xml to a new one without changing the xml itself. In other terms, it means, you can sort or filter data in it.&lt;br /&gt;
: &lt;br /&gt;
: XSL is itself an xml file in as it must be well formed. It must contain well-formed HTML (xhtml) too. Just a portion of how your conditional formattong would look like.&lt;br /&gt;
: &lt;br /&gt;
: You must refer to this stylesheet in the XML file just after the first line (xml declaration)&lt;br /&gt;
: &amp;lt;?xml-stylesheet type="text/xsl" href="cd.xsl"?&amp;gt;&lt;br /&gt;
: &amp;lt;cds&amp;gt;&lt;br /&gt;
:  &amp;lt;cd&amp;gt;&lt;br /&gt;
:   &amp;lt;title&amp;gt;Title 1&amp;lt;/title&amp;gt;&lt;br /&gt;
:   &amp;lt;artist&amp;gt;Artist 1&amp;lt;/artist&amp;gt;&lt;br /&gt;
:   &amp;lt;price&amp;gt;12.99&amp;lt;/price&amp;gt;&lt;br /&gt;
:  &amp;lt;/cd&amp;gt;&lt;br /&gt;
:  &amp;lt;cd&amp;gt;&lt;br /&gt;
:   &amp;lt;title&amp;gt;Title 2&amp;lt;/title&amp;gt;&lt;br /&gt;
:   &amp;lt;artist&amp;gt;Artist 2&amp;lt;/artist&amp;gt;&lt;br /&gt;
:   &amp;lt;price&amp;gt;13.99&amp;lt;/price&amp;gt;&lt;br /&gt;
:  &amp;lt;/cd&amp;gt;&lt;br /&gt;
:  &amp;lt;cd&amp;gt;&lt;br /&gt;
:   &amp;lt;title&amp;gt;Title 3&amp;lt;/title&amp;gt;&lt;br /&gt;
:   &amp;lt;artist&amp;gt;Artist 3&amp;lt;/artist&amp;gt;&lt;br /&gt;
:   &amp;lt;price&amp;gt;9.99&amp;lt;/price&amp;gt;&lt;br /&gt;
:  &amp;lt;/cd&amp;gt;&lt;br /&gt;
: &amp;lt;/cds&amp;gt;&lt;br /&gt;
: &lt;br /&gt;
: cd.xsl might look like this.&lt;br /&gt;
: &lt;br /&gt;
: &amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;
: &amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;&lt;br /&gt;
: &amp;lt;xsl:template match="/"&amp;gt;&lt;br /&gt;
:  &amp;lt;html&amp;gt;&lt;br /&gt;
:  &amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Sample XSL Stylesheet&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
:  &amp;lt;body&amp;gt;&lt;br /&gt;
:  &amp;lt;table&amp;gt;&lt;br /&gt;
:       &amp;lt;tr&amp;gt;&lt;br /&gt;
:           &amp;lt;td&amp;gt;Title&amp;lt;/td&amp;gt;&lt;br /&gt;
:           &amp;lt;td&amp;gt;Artist&amp;lt;/td&amp;gt;&lt;br /&gt;
:       &amp;lt;/tr&amp;gt;&lt;br /&gt;
:       &amp;lt;xsl:for-each select="catalog/cd"&amp;gt;&lt;br /&gt;
:       &amp;lt;xsl:if test="price &amp;amp;gt; 10"&amp;gt;&lt;br /&gt;
:         &amp;lt;tr&amp;gt;&lt;br /&gt;
:           &amp;lt;td&amp;gt;&amp;lt;xsl:value-of select="title"/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
:           &amp;lt;td&amp;gt;&amp;lt;xsl:value-of select="artist"/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
:         &amp;lt;/tr&amp;gt;&lt;br /&gt;
:       &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;
:       &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
:     &amp;lt;/table&amp;gt;&lt;br /&gt;
:   &amp;lt;/body&amp;gt;&lt;br /&gt;
:  &amp;lt;/html&amp;gt;&lt;br /&gt;
: &lt;br /&gt;
: It's just an example, you have to tailor it to your needs. You can find great tutorials on the net, eg. &lt;a href="http://www.w3schools.com"&gt;http://www.w3schools.com&lt;/a&gt; on XML and XSL.&lt;br /&gt;
: &lt;br /&gt;
: : Hi&lt;br /&gt;
: : &lt;br /&gt;
: : I have a problem with filtering my xml file.&lt;br /&gt;
: : &lt;br /&gt;
: : I have created an xml data file containing information about products for a music store (eg. cd's). The xml works fine and is displaying fine. I'm a little confused as to how to filter the xml so that only the CD's that I want displayed are displayed. Does anybody know how to do this?&lt;br /&gt;
: : Please help!!&lt;br /&gt;
: : &lt;br /&gt;
: : Thanks&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: &lt;hr /&gt;&lt;span style="color: Grey;"&gt;To err is human, but to really foul things up requires a computer. (Farmers Almanac)&lt;/span&gt; &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/xml/219410/220274/re-filtering-xml/#220274</guid>
      <pubDate>Sun, 26 Oct 2003 21:17:52 -0700</pubDate>
      <category>XML Development</category>
    </item>
  </channel>
</rss>