输入XML:
<Payheads>
<Allowance>
<Payhead>
<type>fixed</type>
<code>123</code>
<name_en>Chairman Allowance</name_en>
<amount>3000</amount>
<source>SalaryProfile/Allowances/Payhead/CHA/amount</source>
</Payhead>
</Allowance>
<Deduction>
<Payhead>
<type>Fixed</type>
<code>234</code>
<name_en>PF Subscription</name_en>
<source>SalaryProfile/Deductions/Payhead/amount</source>
</Payhead>
</Deduction>
</Payheads>
我希望它是这样的:
<Payheads>
<Allowance>
<Payhead>
<code>123</code>
</Payhead>
</Allowance>
<Deduction>
<Payhead>
<code>234</code>
</Payhead>
</Deduction>
</Payheads>
所以我写了一个xpath表达式:
SELECT DELETEXML(SALARY_PROFILE, '//Payhead/*[not(code)]') INTO RESULT_XML FROM DUAL;
但它会删除Payhead
标记下的所有内容。如果我在*
函数之前删除not
,则会引发错误。怎么解决这个问题?
答案 0 :(得分:1)
*[not(code)]
是
*[not(child::code)]
您需要的是没有缩写的self
轴:
*[not(self::code)]