Java/XML: Counting elements based on parent element's attribute value...
I am developing a Java application to, among other things, extract the
number of child elements based on an attribute value of the parent
element. For example, if I have the following XML:
and I run the program as
java MyProg type1
I want the number "2" returned since there are 2 elements
under . Likewise if I run as
java MyProg type2
I want the number "3" returned. This seems like such a simple
task but I have been unable to restrict the XML parsing to just
one "branch" of the file. When I run my version of the program
the number "5" is always returned. In other words the parser
(DOMParser) is returning the total number of ALL
elements, NOT just the ones within a specific parent
Thanks in advance for any help!