Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

RE: RE: XML::Parser

by ivey (Beadle)
on Jun 20, 2000 at 23:43 UTC ( [id://19086]=note: print w/replies, xml ) Need Help??

in reply to RE: XML::Parser
in thread XML::Parser the difference is that i don't want to define a name for each level...there may be many levels. so, i might have
<section name="top"> <section name="chap1"/> <section name="chap2"> <section name="sub1"/> </section> <section name="chap3"/> <section name="chap4"> <section name="sub2"> <section name="table1"/> </section> </section> </section>
my problem is, in the Handlers definition, how keep a relationship between my "current root section" (ie, the one to which i will be adding the next subsection) and the xml level?

michael d. ivey,

Replies are listed 'Best First'.
RE: RE: RE: XML::Parser
by btrott (Parson) on Jun 20, 2000 at 23:57 UTC
    You can keep a stack of the current level where you are in the XML file. When you get a start tag, push the tag onto the stack; when you get to the end of that tag, pop the tag off the stack. You can use this to define a tree structure of sorts.

    Another option would be to use the "Tree" Style of XML::Parser. Read the docs for that.

    A final option, and a good one, is to use XML::Simple, which may work for you:

    use XML::Simple; XMLin("foo.xml");
    It loads the data into a tree structure, which may or may not work exactly how you want it.

    Or (finally again) you could look into some of the other tree-processing XML modules, like XML::DOM and XML::Twig. They may be overkill for your purposes, though.

RE: RE: RE: XML::Parser
by Adam (Vicar) on Jun 20, 2000 at 23:53 UTC
    I didn't know you could do that. I've not done much with XML.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-23 01:18 GMT
Find Nodes?
    Voting Booth?

    No recent polls found