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

Hi stevieb, That works and thank you for your help. Yes, I agree that just two lines are not enough for thorough testing, and so I tried to run it on the entire file that gets generated dynamically but got the following error:
Code point \u0016 is not a valid character in XML at ./Call_to_snmpwal +k.pl line 32.

This is line $xml->dataElement($subscript_name => $subscript_value);

I am trying to see what else can I find. It seems like data related issue though as from error message it looks like: Some data was generated which is not considered as valid xml character.

@toolid: Thank you for your help, but I was using $string1 in code at:

$xml->startTag($string1);

Replies are listed 'Best First'.
Re^3: What regex changes are needed while creating xml
by Perl300 (Friar) on Jun 25, 2015 at 21:37 UTC
    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?

      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

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

      -stevieb