Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

XML dynamic nesting !!

by onkar (Novice)
on Jan 20, 2010 at 10:11 UTC ( [id://818412]=perlquestion: print w/replies, xml ) Need Help??

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

<A> <B> <C>12345</C> <D> <E> <F>67890</F> </E> </D> <G>abcde</G> </B> <H> <I>83475</I> <J> <K> <L> <M>8732472</M> </L> </K> </J> <N>ewrwkjer</N> </H> </A>
I have the following XML. The nesting is different ( tags M and F are not at same level ) Is there any way to parse this kind of XML dynamically without limiting in any way the nesting ? Please help me with this

Replies are listed 'Best First'.
Re: XML dynamic nesting !!
by Corion (Patriarch) on Jan 20, 2010 at 10:15 UTC

    What have you tried? Any of the XML parsers will parse this kind of XML dynamically without limiting in any way the nesting.

    Of course, if you're trying to use regular expressions to parse XML, that makes things harder. So don't do that.

      <Root> <Databasechecks> <Dbname>DB01</Dbname> <Runquery>some query</Runquery> </Databasechecks> <Databasechecks> <Dbname>DB02</Dbname> <Runquery> <xyz>dfdf</xyz> some query </Runquery> </Databsechecks> </Root>
      here there are two Database checks in the same level . But in the second Databasechecks we have nested xyz tag which is not there in the first Database check. Using XML::Simple module, we can get query result , but we get xyz as hashreference. The code written for first Database check should also parse n number of nodes added to second Databasechecks. How can we know that ? and how can we implement that ? If u know please tell me the solution.

        You should read the XML::Simple documentation about the ForceArray parameter.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2026-04-10 16:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.