472,983 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 software developers and data experts.

xerces perl getNodeValue problem


I have looked and tried everything and i still cant sort this out i
have no idea why this wont work

I am using Xerces Perl on Windows and Debian to try this and it wont
work on both of them.

Basically i am tryin to do simple tree transversale and get the node
values out

I now understand that evetything in DOM is a node including the actual
element values etc so i am using the code below , part done myself
part copied from the examples in the /t dir.

I dont get any values from this code, all i get are blanks and thats
it, if i do getNodeName instead i get "#text". From the commented out
code below this it shows i have tried many different things. I even
tried to copy the code in DOM2Hash.pl but i couldt get it to work for
my code.

Someone must have an answer.

----------------------------- code
use XML::Xerces;
use Getopt::Long;
use Benchmark;
package MyNodeFilter;
use vars qw(@ISA);
@ISA = qw(XML::Xerces::PerlNodeFilter);
$validate = $XML::Xerces::AbstractDOMParser::Val_Always;

### set new parser
my $DOM = XML::Xerces::XercesDOMParser->new();
$sc = 'lr.xsd';
$DOM->setValidationScheme ($sc);
$DOM->setDoNamespaces (1);
$DOM->setDoSchema (1);
$file = 'lr.xml';
$error_handler = XML::Xerces::PerlErrorHandler->new();
$d = $DOM->parse($file);
XML::Xerces::error($@) if $@;
$doc = $DOM->getDocument();
$root = $doc->getDocumentElement();
$filter = MyNodeFilter->new();
$what = $XML::Xerces::DOMNodeFilter::SHOW_ALL;
$walker = $doc->createTreeWalker($root,$what,$filter,1);
XML::Xerces::error($@) if $@;
$node = $walker->getCurrentNode();
#$cd = $cn->getFirstChild();

if ($node->hasChildNodes()) {
my $text;
foreach my $child ($node->getChildNodes) {
if ($child->getNodeType ne
$XML::Xerces::DOMNode::ELEMENT_NODE) {
print "sda";
print $child->getNodeValue();


# if ($child->isa('XML::Xerces::DOMElement')) {
# $k .= $child->getNodeValue();

# }
# if ($child->isa('XML::Xerces::DOMText')) {
# print "asd";
# print $k;
# $new{text} = $k;
# }

# $v = $child-> getElementsByTagName($k);
# print $v;
## if $child->isa('XML::Xerces::DOMText');
# print $text;
# $return->{text} = $text
# if $text !~ /^\s*$/;


--------------------------------- lr.xml
<?xml version="1.0"?>
<room xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

Jul 20 '05 #1
0 3033

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Thomas | last post by:
hi, i upgraded my perl from 5.6/5.6.1 to 5.8 and encounter that xerces writes an xml file with iso-8859-1 instead of utf8 there is an unsolved problem of a false header (xerces writes utf-16...
by: David | last post by:
Hello , I'm trying to parse an XML document a get spicific tags such as email in the code below. I'm using xerces 2.4. However I don't manage to get the value for the email. Can anybody help. ...
by: Ralf Höppner | last post by:
I'm using xerces-c++ 2.4.0 and am testing some functions of it. How can I print the name or the value of a node to console ? I tried: const XMLCh* test=node->getNodeValue(); but it seems to...
by: Dale Gerdemann | last post by:
I've been trying to use DOM level 3 with xerces-2_6_2. There's a sample called samples/DOM3.java, but I've had trouble with compilation. I've downloaded Xerces-J-bin.2.6.2 and...
by: MBR | last post by:
Problem with xerces and C++ Hi, I try the sample from the xerces homepage http://xml.apache.org/xerces-c/program-dom.html, take the iterator and step through the tree: for (DOMNode*...
by: MBR | last post by:
Help! I am using xerces with C++ and want to read the following simple file: <?xml version="1.0"?> <pets> <pet> <name>Tilly</name> <age>14</age> <type>cat</type>
by: MBR | last post by:
Help! Does anybody know a simple example how to use xerces (http://xml.apache.org) with C++ to parse a simple xml file, go from node to node and read the data in the nodes? Thanks, Matthias
by: Matthias Braun | last post by:
Hilfe! Ich habe mir eine Xerces C++ Routine geschrieben, die alle Dokumente des XML-Trees parst. Die folgende rekursive Funktion funktioniert allerdings nicht 100%. Wer kann helfen? Danke,...
by: landoao | last post by:
I have found as following function. It must returns outtext but I don't know about C++ and Xerces-C++ library any more. who can execute this function on C++ and returm me input XML file and Output...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.