in reply to Parse XML to my own objects? (aka XML Data Binding)

This might be of use to you: XML::Simple + Class::MethodMaker.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Parse XML to my own objects?
by conrad (Beadle) on Jun 28, 2005 at 13:50 UTC

    Thanks, but in the same way as XML::Parser, it doesn't quite do what I want — decodes to a data structure, not an object structure, and then afterwards instantiates the data into objects. I'd rather not have to descend the data tree after the fact, examining it for structural correctness in one omniscient sub and blessing it piecemeal into objects… So far as I can see, the one-method-per-class thing I'm looking for is eminently possible but may just not yet have been implemented.

      I think it is going to be rather difficult to create the object while you parse the object tree. You have to have some kind of knowledge of what you are going to expect. At any rate, using a similar technique to the code i linked to, here is a script that parses the example XML from the link you provided. Hope it helps. :)
      direct link to D/L code

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)
      
      For what it's worth... I'd be interested in seeing this :-)

      (Once again, just as I'm trying to get my head around something, a question about it pops up on PerlMonks. This is getting spooky!)