I started with an XML file that I created (by hand). I can easily read it in via XML::Simple which loads it into a nice data structure (dumped with Data::Dumper).
I then started to think OO, and break sub elements of the XML structure down into objects.
I've written a few Perl Objects (been a while) breaking things down into separate classes(packages).
But when I dump the base object through data dumper, it has all the "bless" structures in there. I had hoped to come up with a structure similar to the one that was created by reading in the XML file.
So I guess the question is, is there a way to create objects within Perl and have the data structure come out similar.
Simple Sample of the XML:
Which loads nicely into by XML::Simple:<map> <location name="test"> <items> <item> <desc>some item1</desc> </item> <item> <desc>some item2</desc> </item> </items> <features> <desc>...</desc> </features> </location> </map>
When I try to create it with objects, and sub-objects I get the types and bless(...) stuff mixed in. The inital objects were Features and Item.$VAR1 = { 'location' => { 'items' => { 'item' => [ { 'desc' => 'some i +tem1' }, { 'desc' => 'some i +tem2' } ] }, 'features' => { 'desc' => '...' }, 'name' => 'test' } };
I figure I could create my own XML::Parser but that is more work than I had hoped, also Simple already does a great job.
Please help
In reply to Objects and Data structure similar to XML by Syrkres
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |