Below is my sample 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>
Now I want to find count of occurrence for below combination
<child1>test1</child1>
<child3>test3</child3>
I tried below command
findstr /R /c:"<child1>test1</child1>.*<child3>test3</child3>*" test.xml
but it expects both child1 and child3 in single line.
as here it is in different lines, it is not giving any count.
Can someone please help me to find out window command to fulfill this requirement.
Thanks in advance.
You have to search for either <child1>test1</child1>
or <child3>test3</child3>
:
@echo off
findstr /n /r /c:"<child1>test1</child1>" /c:"<child3>test3</child3>" data4.xml | find /c ":"
With the parameter /C
of find
you can get the number of results.