Name: Patrick Devine
Member since: 2000-10-19 16:27:39
Last Login: N/A
Homepage: http://www.fezbox.com/
Notes: I currently live in the Silicon Valley working for VA Linux and writing a lot of perl code
Some of my projects include:
<foo>
<key>value</key>
<foo2>
<key>value</key>
</foo2>
</foo>
Could be represented logically as:
foo
/ \
key foo2
/ \
value key
\
value
We can build something like this somewhat easily using the
XML::Parser module and using Style => 'Tree' for the
output. Here's a snippet of the code using Data::Dumper to
print out the resulting data structure:use XML::Parser; use Data::Dumper;Which should spit out something with lots of references roughly in the shape of the tree that we're trying to build. The problem with this is that it's still a bit of a ways off, and you'll need to still heavily parse this to get in into any kind of reasonable shape. A module like XML::Simple will do this for you (I believe someone mentioned it on here), although I have to admit, I'm not crazy about the syntax.my $xml = <<END; <foo> <key>value</key> <foo2> <key>value</key> </foo2> </foo> END
$x = new XML::Parser( Style => 'Tree' ); $y = $x->parse( $xml );
print Dumper( $y );
[foo]
key = "value";
[foo2]
key = "value";
[/foo2]
[/foo]
and then have a function which populated a complex hash and
made it very easy to actually represent a whole lot of data
very easily in a text file.
<foo>
<key>value</key>
<foo2>
<key>value</key>
</foo2>
</foo>
which I could then represent in perl as a hash of hashes.
None of this is really an earth shattering discovery, but
what hit me as being strange was that in the midst of all
this I ran upon an an article on xml.com which was written only
a couple of weeks ago entitled What's
wrong with Perl and XML?. There are some 35 different
modules on CPAN in the XML
directory, some of which do really similiar stuff to this
(like XML::Dumper, XML::Config, XML::Grove, XML::Registry),
but why hasn't any one module become the defacto way of
dealing with XML data easily? I guess sometimes even the
simplest of ideas can be some of the most elusive.agntdrake certified others as follows:
Others have certified agntdrake as follows:
[ Certification disabled because you're not logged in. ]
FOAF updates: Trust rankings are now exported, making the data available to other users and websites. An external FOAF URI has been added, allowing users to link to an additional FOAF file.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!