Hi all,

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 35

The 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:

#!/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();
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.