Hi I am getting error while running perl script "can't call method "findnodes" on an undefined value at c:\work\pm.line 17".My script as shown below.
#!/usr/bin/perl
use warnings;
use strict;
use XML::LibXML;
my @xml_files = File::Find::Rule->file->maxdepth(1)->name('*dtc.xml')-
+>in( "c:/file/save");
my $bigXML = XML::LibXML::Document->new( '1.0', 'UTF-8');
my $aggregated; for my $xml_file ( @xml_files ) {
my $doc = XML::LibXML->new->parse_file( $xml_file );
my ( $specNode ) = $doc->findnodes( '//Specification' );
if ( $aggregated ) {
$aggregated = $specNode;
}
else {
my @details = $specNode->findnodes( './Definition' );
$aggregated->addChild( $_ ) foreach @details;
}
}
$bigXML->adoptNode( $aggregated );
$bigXML->toFile( 'aggregated_data.xml' );
I Modified above code like that and this time it gives diffrent error like
"XML::LibXML::Document::adoptNode()--node is not a blessed SV reference at c:\work\pm.line 17 " help me with this error I didn't see this type of error befor.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|