【问题标题】:windows command to find combination of child tags in parent tag in xml filewindows命令在xml文件的父标签中查找子标签的组合
【发布时间】:2018-10-30 10:12:05
【问题描述】:

下面是我的示例 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:"&lt;child1&gt;test1&lt;/child1&gt;.*&lt;child3&gt;test3&lt;/child3&gt;*" test.xml

但它期望 child1 和 child3 在单行中。

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

谁能帮我找出满足这个要求的窗口命令。

提前致谢。

【问题讨论】:

    标签: xml string windows command findstr


    【解决方案1】:

    您必须搜索&lt;child1&gt;test1&lt;/child1&gt;&lt;child3&gt;test3&lt;/child3&gt;

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多