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

Re^4: XML::Rules parsing inside out?

by bfdi533 (Friar)
on Dec 07, 2017 at 22:15 UTC ( [id://1205123]=note: print w/replies, xml ) Need Help??


in reply to Re^3: XML::Rules parsing inside out?
in thread XML::Rules parsing inside out?

I suppose the real reason I do not want to use the rules it provides is that is is then no better than XML::Simple.

The "real" XML is much more complicated and means I have to reference items 6 or 7 levels deep with some labels as long as 38 characters long. So, it would be something like $hash->{'SomeVeryLongCollectionName'}->{'AnotherLowerLevelOfItems'}->{'Summary'}->{'Collections'}->{'Collection'}->{'Item'}->{'Value'} which is VERY unattractive.

The use of XML::Rules allows me, if done properly, to build my own hash and not have to deal with all of those levels and structure which are just unwieldly.

And using the rules as specified, and as you showed in your example, I still have to have the full, very long path to deal with in order to figure out which item I am dealing with but maybe gets me closer. I will try some variations of your code and see where it gets me ...

Replies are listed 'Best First'.
Re^5: XML::Rules parsing inside out?
by Jenda (Abbot) on Jan 09, 2018 at 13:03 UTC

    The results of xml2XMLRules or dtd2XMLRules are just a starting point :-)

    Sometimes they are enough, sometimes you decide to change them to ignore some tags, take just the content ignoring attributes or use an attribute as the hash key and sometimes you add custom rules that'll let you filter or massage the data further or handle the twigs of the XML.

    Especially if the XML is much more complicated, it's better to start with one of them (preferably the later, if you do have a DTD) and then tweak the rules instead of starting with a clean plate.

    This is also why I provide those two as executables, not primarily as methods to call right before the parsing.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-03-29 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found