PL/SQL XML到具有属性和文本()的对象类型
我想将以下XML结构反序列化为PL/SQL对象类型:PL/SQL XML到具有属性和文本()的对象类型,xml,oracle,plsql,Xml,Oracle,Plsql,我想将以下XML结构反序列化为PL/SQL对象类型: <ProcessingInfo> <MrwNumber>000001</MrwNumber> <Station SerialNumber="nice-Attribute">Hello</Station> </ProcessingInfo> 这是我的执行逻辑: DECLARE l_obj processingInfo_t;
<ProcessingInfo>
<MrwNumber>000001</MrwNumber>
<Station SerialNumber="nice-Attribute">Hello</Station>
</ProcessingInfo>
这是我的执行逻辑:
DECLARE
l_obj processingInfo_t;
l_xml XMLTYPE;
BEGIN
l_xml := xmltype(
'<ProcessingInfo>
<MrwNumber>000001</MrwNumber>
<Station SerialNumber="nice-Attribute">Hello</Station>
</ProcessingInfo>');
l_xml.toObject(l_obj);
END;
我知道station\t
对象中缺少了一些内容,因为将提供实际的text(),但它没有在类型中定义。但我确实明白了
另一个问题是,当序列化在对象级别成功进行时,如何访问属性值
附加:当我从
中删除text()=Hello时,序列化似乎有效:
DECLARE
l_obj processingInfo_t;
l_xml XMLTYPE;
BEGIN
l_xml := xmltype(
'<ProcessingInfo>
<MrwNumber>000001</MrwNumber>
<Station SerialNumber="nice-Attribute"></Station>
</ProcessingInfo>');
l_xml.toObject(l_obj);
END;
声明
l_obj处理信息;
l_xml XMLTYPE;
开始
l_xml:=xmltype(
'
000001
');
toObject(l_obj);
结束;
Ok访问属性SerialNumber
处理以下调用:DBMS\u OUTPUT.PUT\u LINE(l\u obj.“MrwNumber”);DBMS_OUTPUT.PUT_LINE(l_obj.“Station”。“@SerialNumber”);
DECLARE
l_obj processingInfo_t;
l_xml XMLTYPE;
BEGIN
l_xml := xmltype(
'<ProcessingInfo>
<MrwNumber>000001</MrwNumber>
<Station SerialNumber="nice-Attribute">Hello</Station>
</ProcessingInfo>');
l_xml.toObject(l_obj);
END;
ORA-19031: XML element or attribute text does not match any in type DEMOGRAPHIC.STATION_T
ORA-06512: at "SYS.XMLTYPE", line 196
ORA-06512: at line 11
19031. 00000 - "XML element or attribute %s does not match any in type %s.%s"
*Cause: The passed in XML tag does not match any in the object type
*Action: Pass a valid canonical XML that can map to the given object type
DECLARE
l_obj processingInfo_t;
l_xml XMLTYPE;
BEGIN
l_xml := xmltype(
'<ProcessingInfo>
<MrwNumber>000001</MrwNumber>
<Station SerialNumber="nice-Attribute"></Station>
</ProcessingInfo>');
l_xml.toObject(l_obj);
END;