I am very new to XML. I have an XML output like the following,
<ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:srch" xsi:schemaLocation="urn:yahoo:srch http://search.yahooapis.com/WebSearchService/V1/WebSearchRelatedResponse.xsd">
<Result>london olympics 2012</Result>
<Result>olympics schedule</Result>
<Result>olympics closing ceremony</Result>
<Result>winter olympics</Result>
<Result>nbc olympics</Result>
<Result>2016 olympics</Result>
<Result>olympics opening ceremony</Result>
<Result>special olympics</Result>
<Result>2008 olympics</Result>
<Result>2020 olympics</Result>
</ResultSet>
I need to count the number of tags in the parent tag .
NodeList nl = doc.getElementsByTagName("ResultSet");
The above gives a single element object. How to know how many results are there in this set?
Thx!
Rahul.
Look at the documentation
http://developer.android.com/reference/org/w3c/dom/NodeList.html
int count = nl.getLength();