in reply to [Solved]:How to remove error: Code point \u0016 is not a valid character in XML

For one thing, I trust you've learned by now (from experience) that whenever you run any shell command like this:
some_proeccess < some.file > some.file
The FIRST thing the shell does is truncate "some.file" (i.e. set it's content to zero bytes); THEN it opens some.file as input to be read via the stdin of some_process. The result is: no data read by the process, because there's no longer any data in the file. Hope you have a backup copy...

For another, when you see something like \u0016, that's a hexadecimal value, You can "grep" for that using a perl one-line like the following:

perl -CS -ne 'print if /\x{0016}/' < some.file
Or, if the file is NOT UTF-16, you could just do:
perl -ne 'print if /\x16/' some.file
Of course, \u0016 isn't the only character that an XML library would reject, and if your file has a bunch of different ones, it gets tiresome fixing them one codepoint at a time as they get reported in error messages.

You can look up how valid vs. invalid XML characters are enumerated (many people use regexes - e.g. on stackoverflow), and run a diagnosis on your file(s) before feeding them to your script (or just add code to your script to filter out the bad characters, if you're sure that just deleting them is The Right Thing To Do).

Replies are listed 'Best First'.
Re^2: How to remove error: Code point \u0016 is not a valid character in XML
by Perl300 (Friar) on Jun 30, 2015 at 20:49 UTC
    Thank you for your response graff. Finally I was able to remove the character that was causing this error "Code point \u0016 is not a valid character in XML".

    I just added some code before

    my $out = IO::File->new()

    The code I added is as below:

    `strings $20150625163139.txt > Temp.txt`; my $temp_file = "Temp.txt"; open($fh, ">", $20150625163139.txt) or die "Could not open file '$file +name' $!"; open(my $fh1, "<", $temp_file) or die "Could not open file 'Temp.txt' +$!"; while(<$fh1>){ print $fh $_; } close $fh; close $fh1; unlink $temp_file;

    So "strings $filename > Temp.txt" removes that character causing error and like many occasions UNIX came to my help this time as well :-)

    Thanks you all for your inputs! If there is any way to mark a node as closed, please let me know and I'll mark this one as closed.

      The usual way is to update the original question's title with (Solved).
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ