Re: Parsing xml using libXML
by runrig (Abbot) on Jul 12, 2013 at 16:44 UTC
|
Something like XML::Rules would build your data structure fairly easily the way you want it, but since I don't know what you want, I don't know what to write. You can start with XML::Simple and decide if that's good enough, or what you don't like, and then switch to XML::Rules. | [reply] |
|
| [reply] |
|
| [reply] |
Re: Parsing xml using libXML
by hippo (Bishop) on Jul 12, 2013 at 13:05 UTC
|
If you really want to roll your own like this, it would seem sensible to use recursion. You are not doing so and are in fact only going to an explicit depth in the tree at any point, hence missing the "graphics" element (and its children if there were any).
| [reply] |
|
well I don't know how to proceed
| [reply] |
|
| [reply] |
Re: Parsing xml using libXML
by zork42 (Monk) on Jul 14, 2013 at 14:18 UTC
|
| [reply] [d/l] |
|
This is messing up the page formatting both within this topic, and on the SoPW page on which this topic appears.
Sorry zork42 but no it doesn't. It seems you have changed your User Settings (Help for User Settings) to turn off code-wrapping and soft-hyphens, so the code isn't wrapped for you.
Its wrapped for me :) you can see yourself (probably) if you try perlmonks.NET or perlmonks.COM or perlmonks.ORG (whichever domain you aren't using, or simply log out) and you'll See also Display Settings, Help for Display Settings , New code wrap options, Why is the PerlMonks page too wide?
Please could someone with god-like powers, or shaq, replace the long line 1 with a short line 1 (so the line numbering remains the same)?
For future reference, PerlMonks FAQ says the general approach to getting a node edited due to formatting,
to /msg nodeowner hey can you fix/edit... [id://]
or to /msg janitors hey can you fix/edit... [id://]
or to consider the node,
but only if its appropriate :) What do Janitors do?, How do I use the power of consideration responsibly?
Hi:)
| [reply] [d/l] [select] |
|
Hey Anonymous Monk thanks for that very helpful post :)
I've now ticked "Auto Code Wrapping" and everything looks fine now :)
Should I still /msg a janitor to get this fixed for other people? (shaq is maybe too new to fix it)
| [reply] |
|
|
Re: Parsing xml using libXML
by Anonymous Monk on Jul 12, 2013 at 14:18 UTC
|
Whats the question, how to build some perl data structure? What kind are you trying to build?
| [reply] |
|
I need to store this xml data into data structures for further use. DS like hash and arrays, So far I have access to all elements except for Graphics nodes and its children
| [reply] |
|
I need to store this xml data into data structures for further use. DS like hash and arrays, So far I have access to all elements except for Graphics nodes and its children
So what data structure? You've posted sample data, now post the corresponding data structure
| [reply] |
|
|