我正在尝试处理这个 XML 文件,我想根据最新的节点值删除所有匹配的节点。在以下示例中,最新节点值为“${DELETE}” 最新节点值将始终为“${DELETE}”,并且该节点将始终位于 XML 文件的底部。
例子:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<projects>
<project id="properties1">
<property name="prop1">some-value</property>
<property name="prop2">abc</property>
<property name="prop3">def</property>
</project>
<project id="properties2">
<property name="prop">testing prop from pom.xml</property>
<property name="prop1">${DELETE}</property>
<property name="prop4">abc</property>
<property name="prop5">xyz</property>
</project>
</projects>
预期输出为:
<projects>
<project id="properties1">
<property name="prop2">abc</property>
<property name="prop3">def</property>
</project>
<project id="properties2">
<property name="prop">testing prop from pom.xml</property>
<property name="prop4">abc</property>
<property name="prop5">xyz</property>
</project>
</projects>