windows 命令在 xml 文件的父标签中查找子标签的组合

windows command to find combination of child tags in parent tag in xml file

下面是我的示例xml

<parent1>
<child1>test1</child1>
<child2>test2</child2>
<child3>test3</child3>
</parent1>

<parent2>
<child1>test1</child1>
<child2>test2</child2>
<child3>test3</child3>
</parent2>

<parent3>
<child1>test1</child1>
<child2>test2</child2>
<child3>test3</child3>
</parent3>

现在我想查找以下组合的出现次数

 <child1>test1</child1>
 <child3>test3</child3>

我试过下面的命令

findstr /R /c:"<child1>test1</child1>.*<child3>test3</child3>*" test.xml

但它希望 child1 和 child3 都在一行中。

因为这里是不同的行,所以没有给出任何计数。

谁能帮我找出 window 命令来满足这个要求。

提前致谢。

您必须搜索 <child1>test1</child1><child3>test3</child3>:

@echo off

findstr /n /r /c:"<child1>test1</child1>" /c:"<child3>test3</child3>" data4.xml | find /c ":"

通过find的参数/C可以得到结果的个数