Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

XML reader and checker

by SmilingBuddha (Acolyte)
on Sep 29, 2004 at 11:16 UTC ( [id://394915]=perlquestion: print w/replies, xml ) Need Help??

SmilingBuddha has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks:

I have some data in XML format:
<job_def> <entry name="DCMAKE"> <option name="QUEUE">batch</option> <option name="RAM">100</option> <option name="LICENSE"> <member> <arg name="NAME">qhvsim</arg> <arg name="NUMBER">1</arg> <arg name="DURATION">2</arg> </member> <member> <arg name="NAME">synopsys</arg> <arg name="NUMBER">1</arg> <arg name="DURATION">3</arg> </member> </option> <option name="RUN_OS"> <member>SUNSOL_58</member> <member>LINUX72</member> </option> </entry> </job_def>

I need to process the above data using some Perl XML parser with the following constraints:
1) I have certain checks that I need to apply on the above data (using DTD).
2) Also, in the above example the user may or may not give certain "arg" names and values for example "NUMBER". In that case I need to take some default value (present in the XML file itself).
3) Also, as can be seen above I need a parser which supports different structures for different "options". For example: option QUEUE takes a scalar value, option LICENSE takes a hash-like structure and option RUN_OS takes an array-like structure.

I was using XML::Simple until now, but that doesn't do anything about DTD nor about default values. My question to you wise monks is how do I go about chossing the XML parser/checker with the above constraints. Any specific names will be greatly appreciated.
Best regards,
SB

Replies are listed 'Best First'.
Re: XML reader and checker
by JediWizard (Deacon) on Sep 29, 2004 at 11:55 UTC

    Chgeck out XML::LibXML. That should give you what you need.

    May the Force be with you

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://394915]
Approved by Roger
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-03-28 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found