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

XML Direction Needed

by set_uk (Pilgrim)
on Dec 10, 2003 at 14:04 UTC ( [id://313711]=perlquestion: print w/replies, xml ) Need Help??

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

I am creating a script which will execute jobs and log their status in a database.

In an effort to make it extensible I want to be able to define the structure of the jobs in XML and then have Perl read the XML template, multiply parts of the XML for as many devices as needed and then create specific entries in the database for each level of the job structure.
(Example XML below shows we will create entries for BATCH, BATCH SECTIONS, JOB_SECTIONS, JOBS)

I'm still learning XML and could do with some help deciding on which approach to use amongst the myriad XML modules out there. I'm thinking Template Toolkit to generate the XML and then perhaps DBIx::XML::DataLoader to get the data into the database.

<?xml version="1.0" encoding="UTF-8"?> <BATCH Name Of The Batch JOB=""> <BATCH_SECTIONS> <UPLOAD> <Dependent_On/> <Section_ID/> <JOB_SECTIONS> <SWITCH_NAME_1> <JOBS> <JOB> <ID/> <TYPE>UPLOAD</TYPE> <SUBTYPE>TNB</SUBTYPE> </JOB> <JOB> <ID/> <TYPE>UPLOAD</TYPE> <SUBTYPE>SLT</SUBTYPE> </JOB> <JOB> <ID/> <TYPE>UPLOAD</TYPE> <SUBTYPE>USAGE</SUBTYPE> </JOB> </JOBS> </SWITCH_NAME_1> </JOB_SECTIONS> </UPLOAD> <PARSE/> <QUERY/> </BATCH_SECTIONS> </BATCH>

janitored by ybiC: Balanced <readmore> tags around example XML

Replies are listed 'Best First'.
Re: XML Direction Needed
by theorbtwo (Prior) on Dec 10, 2003 at 14:13 UTC

    A couple simple tips: First off: XML is case-sensitive. I'd pick a convention, and stick with it. All-lowercase seems to be most common. Second: If SWITCH_NAME_1 is ment to be a counted-type thing, you'll probably have an easier time with SWITCH_NAME count=1, or just SWITCH_NAME, and let the number be implicit with the number of SWTCH_NAMEs before this. Thirdly, BATCH Name Of The Batch JOB="" is simply invalid. Perhaps you mean name="Name Of The Batch".


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      I quickly knocked the eg xml as an example - the SWITCH_NAME_1 is really a placeholder for x number of elements created per switch device. I have yet to determine which is the best method to use to create the elements based on values I have in the database
        Try minixml - http://minixml.psychogenic.com/index.html " MiniXML is a set of PHP classes and Perl modules that allow you to access XML data and create valid XML output with a tree-based hierarchy of elements. It provides an easy, object-oriented interface for manipulating XML documents and their elements. It is currently being used to send requests and understand responses from remote servers in PHP and Perl applications, such as shiphp. MiniXML does not require any external libraries or modules."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found