Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

XML parser

by hakana (Acolyte)
on Nov 28, 2007 at 10:18 UTC ( #653504=perlquestion: print w/replies, xml ) Need Help??
hakana has asked for the wisdom of the Perl Monks concerning the following question:

Wondering if anybody could help me choose xml-parser for my project.
I have a config file in xml and would like to update that with the test results of different tests.
I also would like to export/convert the xml file to html.
I'm looking at XML:LibXML(update) and XML:XPathScript to convert to html.
Also thinking of using XML:Twig to easy update part of the xml file.
What is your suggestion

Replies are listed 'Best First'.
Re: XML parser
by cutlass2006 (Pilgrim) on Nov 28, 2007 at 14:56 UTC

    to be precise; you are seeking a perl module which uses an underlying XML parser (this is usually something like expat).

    as with anything, depends on what you want to do.... are you massaging data ? or are you interpreting an XML file and want to 'do' something ; if the later then you may want to use a streaming parser e.g. XML::LibXML.

    Personally, I find XML::STX to be quite interesting

    As for converting XML to HTML, this is a different problem;

    You might find using XML::LibXSLT is all you will ever need .... at the other end of the scale ... you could probably just use HTML Tidy to convert.

    If you are massaging a lot of data and working in web domain, XSLT is a good route to go down.

    here are some rather old links to perl and XML;

    hth, Jim Fuller
      The long description is that I'm making a test system. The xml file is used for both configuration and saving the results in.
      The first part is that a WEB-GUI is saving witch tests to run.
      <exec> <tc id=001></tc> <tc id=002></tc> </exec>
      Second will the testframework append testinfo to the different nodes and add childs to the nodes.
      <exec> <tc id=001 desc=first test> <ts id=001.001 result=passed/> </tc> <tc id=002 desc=second test> <ts id=002.001 result=failed/> </tc> </exec>
      So the testframework has to be able to find the specific node by using the id and append info/data and child to that node.
      Does anyone have any suggestions how to do this?
        Do you want the output file to have the same order of XML tags as the input file?

        I built an automated test equipment (ATE) configuration and test system using XML::Simple, but I didn't like it because it changed the order of the XML tags between the input and the output. I switched from XML::Simple to XML::Twig and solved this problem.

        After doing this, I thought that maybe XML is not so great for this type of application. I wanted human-readable files that were also easy to parse with a computer. I also wanted to add tags in the future without breaking old files. XML seemed like the right choice but it was not so easy to achieve these goals. Recently I have tried YAML with the same goals, but this has not been so great, either. I am still looking for a better solution.

        Now I think I should use something like YAML, but I should write my own parser.

        It should work perfectly the first time! - toma
Re: XML parser
by Anonymous Monk on Nov 28, 2007 at 11:16 UTC
Re: XML parser
by Mr.Churka (Sexton) on Nov 28, 2007 at 14:54 UTC
    XML Twig is great. It took me a little while to get a feel for it, but it will do everything you need here. why use several modules when one will do the trick?
Re: XML parser
by jrsimmon (Hermit) on Nov 28, 2007 at 14:38 UTC
    I've used XML::Simple for before and found it very, well, simple. Given the descriptions on cpan for twig (A perl module for processing huge XML documents in tree mode) and simple (Easy API to maintain XML (esp config files)), I'd say your description matches up with Simple very well.

    If you do decide to go with simple, a word of advice: read the documentation. XML parsing is the type of process that you need to understand what the API is doing for you to prevent unpredictable results.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://653504]
Approved by moritz
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2017-07-24 03:25 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (348 votes). Check out past polls.