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.