I got the line in the input file which is causing this error:
Code point \u0016 is not a valid character in XML at ./Call_to_snmpwalk_V_1.pl line 35The line is:
GI-eSTB-MIB-NPH::eSTBOobNetworkAddress.0 = STRING: ¸^V^Y(^XóI made a few changes so as to print the generated xml in xml file instead of console and can see that the file generations stops at run time at the above line. That generated xml looks like:
<doc> <GI-eSTB-MIB-NPH> <eSTBOobNetworkAddress> <0>
Updated code now is:
At least I know what exact line/characters are causing trouble now. I trying to find how to avoid this and will update here if I finally get a solution for it.#!/usr/bin/perl use strict; use warnings; use XML::Writer; use XML::Simple; use XML::LibXML; use IO::File; my $out = IO::File->new(">output.xml"); my $xml = XML::Writer->new(OUTPUT => $out, DATA_MODE => 1, DATA_INDENT + => 4); $xml->xmlDecl(); $xml->startTag('doc'); my $check_1 = 0; open(my $fh, "<", "20150626161859.txt") or die "Failed to open file: $!\n"; while(<$fh>) { chomp; next if !length; my ($string1, $string2, $subscript_name, $subscript_value) = / ^(.*?):: ([^\s]+) \.([^\s]+)\s+= \s(.*) /x; if ( $check_1 == 0 ) { $xml->startTag($string1); $check_1 += 1; } $xml->startTag($string2); $xml->dataElement($subscript_name => $subscript_value); $xml->endTag(); } $xml->endTag(); $xml->endTag(); $xml->end(); close $fh; $out->close();
In reply to Re^3: How to remove error: Code point \u0016 is not a valid character in XML
by Perl300
in thread [Solved]:How to remove error: Code point \u0016 is not a valid character in XML
by Perl300
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |