Syrkres has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Objects and Data structure similar to XML
by Joost (Canon) on Jan 29, 2004 at 01:25 UTC | |
|
Re: Objects and Data structure similar to XML
by Roger (Parson) on Jan 29, 2004 at 04:51 UTC | |
|
Re: Objects and Data structure similar to XML
by inman (Curate) on Jan 29, 2004 at 10:44 UTC |