XML::LibXML and getting data from elements/nodes
From: Derrell Durrett (derrell.spam.durrett_at_xilinx.killer.com)
Date: 10/27/04
- Previous message: Jim Keenan: "Re: Namespace and comments on usefulness sought"
- Next in thread: Brian McCauley: "Re: XML::LibXML and getting data from elements/nodes"
- Reply: Brian McCauley: "Re: XML::LibXML and getting data from elements/nodes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 26 Oct 2004 18:50:15 -0600
With the code below, I get the following output:
Use of uninitialized value in concatenation (.) or string at
/home/durrett/proto line 36.
Use of uninitialized value in concatenation (.) or string at
/home/durrett/proto line 36.
Use of uninitialized value in concatenation (.) or string at
/home/durrett/proto line 36.
Use of uninitialized value in concatenation (.) or string at
/home/durrett/proto line 36.
(yes, that's literally 14 empty lines, though some have spaces)
I would expect, based on my (very simplistic) understanding of perldoc
XML::LibXML::Node's 'getData' entry:
getData
If the node has any content (such as stored in a text node )
it can get requested through this function.
to see something more akin to
"platform_id from tblPlatform"
"platform_id"
etc.
Obviously, my expectations are amiss. But how would I get to these
data? Also, it makes no sense to me that half of the nodes returned by
$root->getChildNodes give 'text' as their name (from a debugger session
of the same code):
DB<5> x map {$ARG->getName} $root->getChildNodes
0 'text'
1 'ibom-for-each'
2 'text'
3 'platform'
4 'text'
5 'ibom-next'
6 'text'
7 'installDrops'
8 'text'
Why is this the case?
I'd gladly read a manual, if someone can please point me to one that is
more expansive than the perldoc for XML:LibXML::Node.
Thanks,
Derrell
__CODE__
#! /tools/xgs/perl/5.8.5/bin/perl
# External modules
use strict;
use warnings;
use English;
use XML::LibXML;
# Create a parser object
my $XML_parser = XML::LibXML->new();
my $xml_piece = <<'EOXML';
<?xml version="1.0" encoding="ISO-8859-1"?>
<image
image_id="tblImage.image_id"
imageName="tblImage.imageName"
installMode="tblImage.installMode"
>
<ibom-for-each>"platform_id from tblPlatform"</ibom-for-each>
<platform platDesc="tblPlatform.platform">
</platform>
<ibom-next>"platform_id"</ibom-next>
<installDrops>
<ibom-for-each>"drop_id from tblInstallDrops where
install_id=$install"</ibom-for-each>
<ibom-next>"drop_id"</ibom-next>
</installDrops>
</image>
EOXML
# No default attributes.
$XML_parser->complete_attributes(0);
my $doc = $XML_parser->parse_string( $xml_piece );
my $root = $doc->getDocumentElement;
print map {"$ARG\n"} map {$ARG->getData} $root->getChildNodes;
-- Derrell Durrett Xilinx, Inc. / Software Productivity Tools Longmont, Colorado / 720.652.3843 ***remove bits about .processed meats and .death from e-mail to reply
- Previous message: Jim Keenan: "Re: Namespace and comments on usefulness sought"
- Next in thread: Brian McCauley: "Re: XML::LibXML and getting data from elements/nodes"
- Reply: Brian McCauley: "Re: XML::LibXML and getting data from elements/nodes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|