Salman
Salman

Reputation: 31

to count specific Data in XML file automatically

I work on XML files everyday, and it requires to check and count any specific tag available in each XML file.

Let suppose there are 100 XML files saved in a folder, currently i am opening each XML file and then find for particular tag to see how many times it appears.

It takes lots of time to open 100 XML files one by one and count any specific tag within it.

IS there anyway i can do it automatically,

I will be very thankful for you

Upvotes: -1

Views: 214

Answers (1)

Dominique
Dominique

Reputation: 17543

Please don't shoot me down for this, but when I read the tags of this question: Excel, VBA, I can only ask: WHY???

I have a bunch of logfiles, containing XML requests and responses, containing a <Header_Message> tag, so I have launched following very simple command (with a part of the results):

grep -c "<Header_Message>" *.log
2022-01-03.log:531
2022-01-04.log:3345
2022-01-05.log:5101
2022-01-06.log:5770
2022-01-07.log:4165
2022-01-10.log:14639
2022-01-11.log:20824
2022-01-12.log:21409
2022-01-13.log:14
...

I looked for a FindStr similar command, but I didn't find a way to count using FindStr, so you might end up with a Cygwin environment (Windows programs behaving like UNIX commands).

I can't deny you did add the Excel and the VBA tags to this question, so you might want to use the Shell() VBA command for launching commandline commands, something like Shell("grep -c '<Header_Message>' *.log >C:\Temp\outputfile.txt"), and then you can start analysing the content of outputfile.txt.

Upvotes: 1

Related Questions