'How to get the child element name from an xml file in C++

I am attempting to write code that will do the following:

  • Collect filename and rootnode name from CLI
  • Loop through element children of the root
  • Return a count of how many element children are in the file

I'm super new to programming and I am having a hard time figuring out how to get the element child name from the file.

Essentially, the command line input would look like this:

./programname filename rootnodename

The xml file would look something like this:

<root_node>
     <child_node>child node 1 text</child_node>
     etc.
<\root_node>

The program should be able to run with any unknowable file in this format, so my question is: how do I grab the name of the child_node so that I can loop through the element children using the child_node name?

Thanks in advance for any tips you have, and apologies if this is a silly question - I'm very new to this!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source