Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: "PAR'ing" XML configs?

by holli (Abbot)
on Aug 08, 2005 at 18:07 UTC ( #481957=note: print w/replies, xml ) Need Help??


in reply to "PAR'ing" XML configs?

...but I want to use XML for the config file
I hope for the sake of your immortal soul, that in your xml you store something more complicated than
<options> <section name="users"> <option name="larry" value="in0n3line?" /> <option name="dominus" value="errorme$$age!" /> </section> </options>
Such data, which could far easier (and more robust than with XML::Simple (sometimes it's a PITA to get XML::Simple to parse or write how you want it to)) written as classic INI-Files. Using XML for this may be considered NTBI™ (Not The Best Idea). For a deeper discussion refer Configuration file design an my reply to it.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: "PAR'ing" XML configs?
by guice (Scribe) on Aug 08, 2005 at 19:15 UTC
    It is far more complex than that. A small taste of it (a bit large to write it out fully)
    <opt> <tmpl_xml> <table> <pkey>key1</pkey> <pkey>ky2</pkey> </table> </tmpl_xml> <config> <bad_procs> <proc name="procd" /> <proc name="procd2"> <exempt>hostname</exempt> </proc> </bad_procs> <perm_checks> <file group="grp" path="/etc" user="user" perm="00755" /> </perm_checks> <oneliners> <command id="non-root RC scripts"> find /etc/rc?.d /etc/init.d ! -user root </command> </oneliners> </config> </opt>

    There's really much more than that, but it's just a small sample of it. It's a configuration audit check/data collector for remote systems. The config is to define all files to capture, processes to check good/bad, exceptions, port checks, etc.... It's actually a rather large XML file (443 lines--244 lines with AttrIndent off). Currently I'm using XML::Simple to parse it, but not sure if that's really the best way to parse it. But for now, it's the only possible resource I have (can't compile expact due removal of our compile tools).

    sometimes it's a PITA to get XML::Simple to parse or write how you want it to

    Yeah, fully aware of that. This is why I'm starting with the config file. I'm getting it exactly the way I want it and getting it parsed just how I want it with XML::Simple. Right now, everything's pretty much near perfect (I have to access my one-liners one more hash level than I'd like, but it's no biggy--only an additiona 8 characters to type in my code, once).

    -- philip
    We put the 'K' in kwality!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-12-09 18:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?