我有一个 oracle 查询来生成下面的 xml 结果,我只想检查SUBQUERY和 COL_LIST_ITEM 节点内是否有任何属性值,而不是其他节点。如果节点具有属性值而不是写“它具有属性值”,否则“没有属性值”。我不确定我的代码是否正确!有没有办法做到这一点?
<VIEW xmlns="http://xmlns.oracle.com/ku" version="1.0">
<SCHEMA value1="USER1">USER2</SCHEMA>
<NAME value1="VIEW_TBL_A">VIEW_TBL_B</NAME>
<COL_LIST>
<COL_LIST_ITEM>
</COL_LIST_ITEM>
<COL_LIST_ITEM src="2">
<NAME>FIELD_A2</NAME>
</COL_LIST_ITEM>
</COL_LIST>
<SUBQUERY value1="SELECT FIELD_A1
FROM TBL_A
WHERE FIELD_A1 = 111">SELECT FIELD_A1, FIELD_A2
FROM TBL_A
WHERE FIELD_A1 = 111</SUBQUERY>
</VIEW>
这是我的代码
using (OracleConnection conn1 = new OracleConnection(oradb1))
{
conn1.Open();
using (OracleCommand crtCommand = new OracleCommand("SELECT dbms_metadata.get_sxml('VIEW','VIEW_TBL_A') FROM dual;", conn1))
{
XmlDocument xml = new XmlDocument();
xml.LoadXml(crtCommand.ExecuteScalar().ToString());
}
}