如果属性与另一个文件中的值匹配,如何从XML中删除节点?

时间:2018-11-19 21:06:53

标签: xml xslt

假设我有一个像下面这样的xml文件:

<client name="Mary" id="123"/>
<client name="Anthony" id="456"/>
<client name="Theo" id="789"/>

我想从另一个文件中删除ID等于值之一的所有节点。该其他文件是纯文本文件,但是如果可以简化解决方案,则可以将其更改为xml。

List_Of_Ids.txt:
123
789

我需要的最终结果是:

<client name="Anthony" id="456"/>

还要考虑到客户端xml列表和id列表都包含数百条记录。

我想做以下事情:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:param name="ids-to-delete" select="123, 789"/>
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="client[id = $ids-to-delete]"/>
</xsl:stylesheet>

但是,我不想列出要删除的所有ID,而是希望从List_Of_Ids.txt中读取它们。

一个善良的灵魂可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

使用mpirun detected that one or more processes exited with non-zero status, thus causing the job to be terminated. The first process to do so was: Process name: [[62648,1],2] Exit code: 2 ,请参见https://www.w3.org/TR/xpath-functions/#func-unparsed-text-lines

相关问题