Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

filtering xml

dodgedodge Posts: 163Member
Hi

I have a problem with filtering my xml file.

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?
Please help!!

Thanks

Comments

  • lillulillu Posts: 308Member
    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.

    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.

    You must refer to this stylesheet in the XML file just after the first line (xml declaration)
    <?xml-stylesheet type="text/xsl" href="cd.xsl"?>


    Title 1
    Artist 1
    12.99


    Title 2
    Artist 2
    13.99


    Title 3
    Artist 3
    9.99



    cd.xsl might look like this.

    <?xml version="1.0"?>



    Sample XSL Stylesheet













    Title Artist



    It's just an example, you have to tailor it to your needs. You can find great tutorials on the net, eg. http://www.w3schools.com on XML and XSL.

    : Hi
    :
    : I have a problem with filtering my xml file.
    :
    : 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?
    : Please help!!
    :
    : Thanks
    :

    [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)

  • dodgedodge Posts: 163Member
    Hi
    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.
    But, I have gone down an alternative path, so thanks anyway.

    dodge




    : 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.
    :
    : 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.
    :
    : You must refer to this stylesheet in the XML file just after the first line (xml declaration)
    : <?xml-stylesheet type="text/xsl" href="cd.xsl"?>
    :
    :
    : Title 1
    : Artist 1
    : 12.99
    :
    :
    : Title 2
    : Artist 2
    : 13.99
    :
    :
    : Title 3
    : Artist 3
    : 9.99
    :
    :
    :
    : cd.xsl might look like this.
    :
    : <?xml version="1.0"?>
    :
    :
    :
    : Sample XSL Stylesheet
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    TitleArtist
    :
    :
    :
    : It's just an example, you have to tailor it to your needs. You can find great tutorials on the net, eg. http://www.w3schools.com on XML and XSL.
    :
    : : Hi
    : :
    : : I have a problem with filtering my xml file.
    : :
    : : 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?
    : : Please help!!
    : :
    : : Thanks
    : :
    :
    : [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)
    :
    :

Sign In or Register to comment.