Hi there Monks!
I am working on this XML file but my problem is that I need to
find a way to strip off the first line on the XML file before using
XML::XPATH to process it, because it is giving me an error, without this line it works:
encoding specified in XML declaration is incorrect at line 1, column 3
+0, byte 30:
<?xml version="1.0" encoding="utf-16"?>
I have no choice but remove or ignore this line.
Is there a way to tell XML::XPATH to ignore this first line
<?xml version="1.0" encoding="utf-16"?>
and start after that? If not, how would you approach this
situation to get rid of this first line and process the rest of file?
Here is the code
#!/usr/bin/perl
use strict;
use warnings;
use XML::XPath;
my $xp = XML::XPath->new(filename => '/xml_test.xml');
foreach my $row ($xp->findnodes('/HOME/Account')) {
my $nodeset = $row->find('Record');
foreach my $node ( $nodeset->get_nodelist ) {
my $account = $node->find( 'accnumber')->string_value;
print "\n $account \n";
}
}
Thnaks for looking!
-
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.
|