[ Date Index ][
Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sunday 05 October 2003 11:44 am, Neil Williams wrote:
> Could anyone help with an example script - I can't make sense of the POD
> output, it just talks of references and nodes, there's no example code for
> actually processing the nodes.
whoops, forgot an example:
use XML::LibXML;
use strict;
my ($xmlDoc);
eval { $xmlDoc = $parser->parse_string($content) };
if ( my $err = $@ ) {
die $err;
## Or something more sensible..
}
handleRow($_) foreach ($xmlDoc->findnodes('/ISBNORG/RECORD'));
sub handleRow
{
my $row = shift;
my %Node = ();
foreach my $node ($row->findnodes('./*'))
{
my $data = ($node->getFirstChild()) ? $node->getFirstChild()->getData() :
undef;
$Node{ $node->nodeName } = $data;
}
## XXX: Do somethign with each record now, all data is in %Node.
## e.g $Node{'SHORTTITLE'} would now contain:
## "Perl in a nutshell :"
return;
}
## == end ==
~ Theo
- --
Theo Zourzouvillys
<theo@xxxxxxxxxxxxxxxx>
<http://theo.me.uk/>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/gCRm448CrwpTn6YRAu0OAJ0Wut5glNF9J7DlfOdRMrGQkaB25QCgxqJW
gfBOTvEao+kSdwbgxlgp44w=
=6QHJ
-----END PGP SIGNATURE-----
--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.