Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: XML::Smart - Development in final stage. (beta is out)

by vladb (Vicar)
on May 13, 2003 at 05:59 UTC ( #257648=note: print w/replies, xml ) Need Help??


in reply to XML::Smart - Development in final stage. (beta is out)

You are correct, I did run into problems you are describing here. However, I found temporary remedy by instantiating an XML::Simple object with certain options that simplify the resulting perl structure somewhat. Here's an example code snippet:
use strict; use XML::Simple; use Data::Dumper; my $xs = new XML::Simple(forcearray => 1, forcecontent => 1, contentkey => '_content', keyattr => []); my $xml; { local $/ = undef; $xml = <DATA>; } my $xmlHash = $xs->XMLin($xml); print "xmlHash:\n" . Dumper($xmlHash); __DATA__ <?xml version="1.0" encoding="iso-8859-1"?> <hosts> <server os="linux" type="redhat" version="8.0"> <address>192.168.0.1</address> <address>192.168.0.2</address> </server> <server address="192.168.2.100" os="linux" type="conectiva" version= +"9.0"/> </hosts>
And the ouptut is
xmlHash: $VAR1 = { 'server' => [ { 'os' => 'linux', 'address' => [ { '_content' => '192.168.0.1' }, { '_content' => '192.168.0.2' } ], 'version' => '8.0', 'type' => 'redhat' }, { 'os' => 'linux', 'address' => '192.168.2.100', 'version' => '9.0', 'type' => 'conectiva' } ] };
Note that I force the '_content' key which assures that there'll be much less inconsistancy in the xml structure (HASHREF or ARRAYREF etc).

I was also wondering if you had done any benchmarking on your module? I have a sizable script (~4000 lines) that makes extensive use of the XML::Simple module and was wondering if converting to, say, your smart module would slow it down considerably (and this being part of a larger web application may be the least I'd want to have :)?

Otherwise, your attempt does look worthwhile and promising :-)

_____________________
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce
the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true."

Robert Wilensky, University of California

Replies are listed 'Best First'.
Re: Re: XML::Smart - Development in final stage. (beta is out)
by gmpassos (Priest) on May 13, 2003 at 14:47 UTC
    Thanks to like it! ;-P

    I'm opened for new ideas for XML::Smart too, since you share the same problems to work with the previous resources for XML!

    About benchmark, I can't say that I made tests yet, since this is the last thing to do! But the load of the XML files are faster than XML::Simple! For XML::Simple you make a tree, and than it parse all the HASH tree again to make it in the right format. With XML::Smart it make the tree directly in the right format. What can be slower of course, is the access of keys or indexes in the object, since this paste through a TIEHASH and a TIEARRAY, what can't be compared to the direct access of HASHes and ARRAYs!

    But note that since is easier to use XML::Smart, you make a code cleanner, that work directly in what you want, what help a lot in the speed.

    But if you have experience with hight volumes of XML data, you can help me with the benchmark! If you could make some bench tests for XML::Simple, specially with difficult problems, I can compare with XML::Smart and make everything possible to make it faster. I will appreciate a lot your help in this!

    Graciliano M. P.
    "The creativity is the expression of the liberty".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://257648]
help
Chatterbox?
marioroy At a large firm, had to awaken a security guy a few times so that nobody would catch him sleeping.
marioroy On a large dairy farm, almost went off the road with a 10 wheeler from exhaustion. On the farm, almost went off the silo with a big tractor. At the Fransiscan monastery, almost slipped off the dome while painting it.
[marioroy]: In Saudi Arabia caught fire but didn't burn. I think angels exist.
Lady_Aleena clean up after dinner finally.
[Discipulus]: uch! so we are twice lucky to have MCE..;=)
[marioroy]: Working a midnight graveyard shift, on the way home ran out of gas. just 2 minutes later somebody stops with a small tank of gas. It's wierd. There's always someone nearby for some reason.
[Lady_Aleena]: I was the one who stop[ed in the middle of a cold night to pick up a small family walking to a gas station. I got a few gallons of free gas for the round trip, and the grandmother said she'd pray for me.
[marioroy]: Folks do not know it, but MCE was ridiculously difficult. At Niagra Falls, heard a voice on enabling Grace while in the mist boat. That 10x performance is possible.
[marioroy]: Lady_Aleena Angels on earth are real people. That's awesome.

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2017-05-29 08:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?