1

I have a function that generates a clob with xml like

<?xml version="1.0"?>
<OBJECT_TYPES meta_version="1.0"><OBJECT_TYPE type_name="Absorber "Geo""/>
</OBJECT_TYPES>

When I try to escape double quote with \" I get an error:

Error: Required white space was missing. Line: (1) <OBJECT_TYPE type_name="Absorber \"Geo\""/>

I can't understand why it happens.

adelak
  • 647
  • 4
  • 11
  • 25

1 Answers1

4

The way to escape a double quote character inside a double-quoted attribute value in XML is to use &quot;:

<?xml version="1.0"?>
<OBJECT_TYPES meta_version="1.0"><OBJECT_TYPE type_name="Absorber &quot;Geo&quot;"/>
</OBJECT_TYPES>

Alternatively you can use single quotes around the attribute value which then allows literal double quotes within it

<?xml version="1.0"?>
<OBJECT_TYPES meta_version="1.0"><OBJECT_TYPE type_name='Absorber "Geo"'/>
</OBJECT_TYPES>

Similarly, to escape single quote characters within a single-quoted attribute you use &apos;

<OBJECT_TYPE type_name='Ian&apos;s type'/>
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183