Extracting Data from XML using XSL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    Extracting Data from XML using XSL

    Hi,
    I want to know how to extract information from a XML file using a XSL style sheet using perl.
    I have alreday written a XSL for a XML file.
    My requirement is to apply this XSL on the xml which in turn gives me a csv output.
    Which module shuld i use for this?
    Thanks
    Raghu
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    I'm not very familiar with many Perl modules but the logic behind this doesn't seem that hard.

    CSV files are just files containing comma-separated values.
    You could use the XSL to transform the XML into comma-separated values and then just output this to a csv file.

    Upon doing a quick google search on the topic turned up a lot of examples...most of them weren't using Perl but since this is mostly about using XML (and XSL) to produce comma-separated values....it seems like it shouldn't be too hard to apply this to Perl.

    Googling also revealed that you're going to need to use the XML::XSLT and XML::DOM modules.



    -Frinny

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      And if you want to get really freaky with your CSV file creation, you can use the DBD::CSV module, which allows you to treat a csv file as a database.

      Also, simply search on the CPAN site for CSV and you will find other modules for reading/writing CSV files.

      Regards,

      Jeff

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        That module sounds awesome numberwun!

        :)

        Hope it helps the OP

        Comment

        • gpraghuram
          Recognized Expert Top Contributor
          • Mar 2007
          • 1275

          #5
          Hi,

          Thanks for the suggestion.
          I was able to use XML::XSLT to achive this.

          Thanks
          Raghu

          Comment

          • numberwhun
            Recognized Expert Moderator Specialist
            • May 2007
            • 3467

            #6
            Glad that it worked for you Raghu.

            Comment

            Working...