I am creating a simple XML 1.0 file using a short PL / SQL function populated with data from a table.
Data from the table also contains HTML characters, such as <>, etc. For these special characters, I built a short search and replace function that looks like this:
newXmlString := REPLACE(xmlString, '&', '&' ); newXmlString := REPLACE(newXmlString, '\', '' ); newXmlString := REPLACE(newXmlString, '<', '<' ); newXmlString := REPLACE(newXmlString, '>', '>' ); newXmlString := REPLACE(newXmlString, '"', '"' ); newXmlString := REPLACE(newXmlString, '''', ''' );
Now the table has more data, which is why the XML file cannot be checked due to special control characters ( https://en.wikipedia.org/wiki/Control_character ) like:
- ETX (End of text)
- SYN (synchronous idle)
Note. Not every control character damages XML file validation! Linear transitions or carriage returns are still possible.
Of course, now I can search for and replace them, for example:
newXmlString := REPLACE(newXmlString, chr(3), '' );
But is there a built-in function or something like a library that I can use with PL / SQL without listing and finding and replacing them?
UPDATE 1
I also tried using the dbms_xmlgen.getxml function, but this function throws an error message due to the unsuccessful conversion of w980> to escaped char. '+
UPDATE 2
I tried using REGEXP_REPLACE(STRING_VALUE,'[[:cntrl:]]') , which will work, but it will also remove the line breaks that we want to keep, and also does not affect the validation of the XML file.