I have some XML files for which I want to get the count of nodes. However, I don't want to go and start coding. I have checked some XML tools like Notepadd++ XML Plugin, Cygwin xmllint, XML Notepad 2007, but none of them provide this feature.
Basically, I need kind of a summery count of nodes. Is there any software that can do that?Googling seems to only provide solution that require programming.
6 Answers
I found this online tool that you may find useful: . Examples are included on the same page.
5To elaborate on the Notepad++ answer, you can also use the Count button in the search dialogue box. My XML file has thousands of nodes and it gave me the count of a particalur <node>value</node> in a couple of seconds.
The find all option was less useful because it shows by line so my node got hidden away.
The final alternative I found was the Mark option which will mark the string and (optionally) set a bookmark. The bookmark doesn't solve the problem when a node and children are on a single line but you can at least jump to the next line with the marked text by pressing F2.
Added: This works ok when you have lots of the same values but if you're trying to discover the different values you need a way to exclude. I ended up searching with a Regular Expression to filter out the values I found as I went along so <node>(?!Value1|Value2|Value3).*</node> The group excludes the values that you have found
I just keep coming back to Notepad++ for these jobs, it's a wonderful program
1In some simple cases, the easiest way is to open XML file in a web browser window (e.g. Chrome displays XML tree), then count items using 'find on page' function (usually CTRL+F or CMD+F) and paste your node identity string like this <o id= for nodes like that <o url="...">...</o>. The browser will count found occurrences for you. Essentially, any text editor will do that job also.
Not sure how complex your count must be, but I had similar issue and just used notepad++ search option.
I guess it's tedious if you've got a lot of nodes to count and a lot of files, but it's good as a one off.
Use command line
find /C "<NodeName or Pattern>" <filename>.xml
should give you the count of the nodes you are looking for.
I had similiar issue, needed to count the number of nodes in an xml, non-programatically. The approach I took was to convert the xml to a csv, and then do the math in excel.
Online tool to convert XML to CSV -
In Excel, use formula COUNTA
2