in reply to Re^2: What regex changes are needed while creating xml
in thread [Solved]:What regex changes are needed while creating xml

I searched for error: "Code point \u0016 is not a valid character in XML at ./Call_to_snmpwalk.pl line 32" It seems that this error is being generated due to control characters present in the text which are not allowed in xml. So I have two options:

1) Remove these control characters from the file and then print: I have tried this using

perl -pe's/\x08//g' <file1.xml >file1.xml

But this gives error: Bad name after g' at <script_name>.pl line 13.

2) To actually generate an xml (actual .xml file) from code and put the text that is converted in xml into this file and then read it. Do anyone have any suggestions on point 1 or 2?

Replies are listed 'Best First'.
Re^4: What regex changes are needed while creating xml
by hippo (Archbishop) on Jun 25, 2015 at 22:56 UTC

    Never redirect both from and to the same file at the same time: the file will be clobbered. Instead use the -i option to edit in place. Don't forget the trailing semicolon either.

    perl -pi -e 's/\x08//g;' file1.xml
Re^4: What regex changes are needed while creating xml
by stevieb (Canon) on Jun 25, 2015 at 21:43 UTC

    It would be helpful if you could show a couple of the lines that are causing you this specific grief.

    -stevieb