Iterate over DOM Nodelist

I have an XML in the form of
I want to iterate over all the elements inside fb_responses, so that whenever a tag is encountered like fb_input_approve or fb_response, I can do some action.
This is what I am doing (attached code snippet)
But in the nodelist, I am getting only one element.

Can someone please let me know how to achieve this using DOM

NodeList responsesNodeList = document.getElementsByTagName("fb_responses");
       System.out.println("resposne node list lenght :  "+responsesNodeList.getLength());
       for(int i=0; i<responsesNodeList.getLength(); i++) {
           Node childOfResponses = responsesNodeList.item(i);
           if (childOfResponses.getNodeType() == childOfResponses.ELEMENT_NODE) {
                   String strChildOfResponses = childOfResponses.getNodeName();
                   System.out.println(childOfResponses.getNodeName()+"  :  "+childOfResponses.getNodeValue());
                   if(strChildOfResponses.equalsIgnoreCase("fb_input_approve")) {
           IXMLCreator cfxml = new CreateApproverXML();
           StringBuffer xmlChunck = cfxml.getXMLChunck(response_id, session);

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In the XML you only have one <fb_responses> so thats why you only get one element. :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Which XMLReader are you using by the way?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.