Another question about Oracle’s Dbms_XmlDom
functionality. This time about setting attributes. Here’s the code:
DECLARE
doc_ dbms_XmlDom.DomDocument := Dbms_XmlDom.newDomDocument;
nd_ dbms_XmlDom.DomNode;
tag_ dbms_XmlDom.DomElement;
data_in_ VARCHAR2(50) := '£';
out_ VARCHAR2(32000);
BEGIN
Dbms_XmlDom.setVersion (doc_, '1.0" encoding="UTF-8" standalone="yes');
tag_ := Dbms_XmlDom.createElement (
doc => doc_,
tagName => 'coreProperties'
);
Dbms_XmlDom.setAttribute(tag_, 'myAttribute', data_in_);
nd_ := Dbms_XmlDom.appendChild (Dbms_XmlDom.makeNode(doc_), Dbms_XmlDom.makeNode(tag_));
out_ := Dbms_XmlDom.getXmlType(doc_).getClobVal;
Dbms_XmlDom.freeDocument (doc_);
Dbms_Output.Put_Line (out_);
END;
And here’s the output:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<coreProperties myAttribute="£"/>
I need the output to be:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<coreProperties myAttribute="£"/>
In other words, I want to prevent the &
in the input data (which gets fed into the attribute’s value) from escaping into &
by the function setAttribute()
. Can it be done?