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

问题描述 投票:0回答:1

下面是我的示例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都是单行。

因为它在不同的行,它没有给任何计数。

有人可以帮我找出窗口命令来满足这个要求。

提前致谢。

xml string windows command findstr
1个回答
0
投票

你必须搜索<child1>test1</child1><child3>test3</child3>

@echo off

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

使用/C的参数find,您可以获得结果数。

© www.soinside.com 2019 - 2024. All rights reserved.