Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:54:56+00:00 2026-06-07T03:54:56+00:00

How to traverse node in without considering node which is child node of it.

  • 0

How to traverse node in without considering “” node which is child node of it.

With bellow example code i am getting 9 loops. But i should get 3 loops.

NodeList TravellerInfo=BookingresponseEle.getElementsByTagName(“TravellerInfo”);

Element TravellerInfoEle=(Element)TravellerInfo.item(0);

NodeList Items=TravellerInfoEle.getElementsByTagName(“Item”);

XMl is below

<TravellerInfo>        
<Item>          
    <TicketNumber>5899553184513</TicketNumber>          
    <PaxType>ADT</PaxType>          
    <Title> MR</Title>          
    <FirstName>TEST</FirstName>          
    <LastName>TEST</LastName>          
    <DateOfBirth />          
    <SegmentInformation>            
    <Item>             
        <AirlinePNR>MWVGUH</AirlinePNR>              
        <TicketNo>5899553184513</TicketNo>              
        <FlightNumber>2777</FlightNumber>              
        <Origin>BLR</Origin>              
        <Destination>VTZ</Destination>              
        <DepartureDateTime>24/07/2012 06:50</DepartureDateTime>              
        <ArrivalDateTime>24/07/2012 08:55</ArrivalDateTime>              
        <AirCraftType>AT7</AirCraftType>              
        <CarrierCode>9W</CarrierCode>              
        <ClassCode>W</ClassCode>              
        <FareBasis>W2SA14JK</FareBasis>              
        <FrequentFlyerNumber />              
        <SpRequest />              
        <MealsPreference>VGML meals status : UN</MealsPreference>            
    </Item>            
    <Item>              
        <AirlinePNR>MWVGUH</AirlinePNR>              
        <TicketNo>5899553184513</TicketNo>              
        <FlightNumber>2704</FlightNumber>              
        <Origin>VTZ</Origin>              
        <Destination>MAA</Destination>              
        <DepartureDateTime>24/07/2012 19:15</DepartureDateTime>              
        <ArrivalDateTime>24/07/2012 21:00</ArrivalDateTime>              
        <AirCraftType>AT7</AirCraftType>              
        <CarrierCode>9W</CarrierCode>              
        <ClassCode>W</ClassCode>              
        <FareBasis>W2SA14JK</FareBasis>              
        <FrequentFlyerNumber />              
        <SpRequest />              
        <MealsPreference>VGML meals status : UN</MealsPreference>            
    </Item>  
    </SegmentInformation>        
 </Item>
 <Item>          
    <TicketNumber>5899553184512</TicketNumber>          
    <PaxType>CHD</PaxType>          
    <Title> MSTR</Title>          
    <FirstName>TESTC</FirstName>          
    <LastName>TESTC</LastName>          
    <DateOfBirth>15/07/2009</DateOfBirth>          
    <SegmentInformation>            
    <Item>              
        <AirlinePNR>MWVGUH</AirlinePNR>              
        <TicketNo>5899553184512</TicketNo>              
        <FlightNumber>2777</FlightNumber>              
        <Origin>BLR</Origin>              
        <Destination>VTZ</Destination>              
        <DepartureDateTime>24/07/2012 06:50</DepartureDateTime>              
        <ArrivalDateTime>24/07/2012 08:55</ArrivalDateTime>              
        <AirCraftType>AT7</AirCraftType>              
        <CarrierCode>9W</CarrierCode>              
        <ClassCode>W</ClassCode>              
        <FareBasis>W2SA14JK</FareBasis>              
        <FrequentFlyerNumber />              
        <SpRequest />              
        <MealsPreference>VGML meals status : UN</MealsPreference>            
    </Item>            
    <Item>              
        <AirlinePNR>MWVGUH</AirlinePNR>              
        <TicketNo>5899553184512</TicketNo>              
        <FlightNumber>2704</FlightNumber>              
        <Origin>VTZ</Origin>              
        <Destination>MAA</Destination>              
        <DepartureDateTime>24/07/2012 19:15</DepartureDateTime>              
        <ArrivalDateTime>24/07/2012 21:00</ArrivalDateTime>              
        <AirCraftType>AT7</AirCraftType>              
        <CarrierCode>9W</CarrierCode>              
        <ClassCode>W</ClassCode>              
        <FareBasis>W2SA14JK</FareBasis>              
        <FrequentFlyerNumber />              
        <SpRequest />              
        <MealsPreference>VGML meals status : UN</MealsPreference>            
    </Item>            
    </SegmentInformation>        
    </Item>
          <Item>          
    <TicketNumber>5899553184514</TicketNumber>          
    <PaxType>ADT</PaxType>          
    <Title> MR</Title>          
    <FirstName>TESTT</FirstName>          
    <LastName>TESTT</LastName>          
    <DateOfBirth />          
    <SegmentInformation>            
    <Item>             
        <AirlinePNR>MWVGUH</AirlinePNR>              
        <TicketNo>5899553184514</TicketNo>              
        <FlightNumber>2777</FlightNumber>              
        <Origin>BLR</Origin>              
        <Destination>VTZ</Destination>              
        <DepartureDateTime>24/07/2012 06:50</DepartureDateTime>              
        <ArrivalDateTime>24/07/2012 08:55</ArrivalDateTime>              
        <AirCraftType>AT7</AirCraftType>              
        <CarrierCode>9W</CarrierCode>              
        <ClassCode>W</ClassCode>              
        <FareBasis>W2SA14JK</FareBasis>              
        <FrequentFlyerNumber />              
        <SpRequest />              
        <MealsPreference>VGML meals status : UN</MealsPreference>            
    </Item>            
    <Item>              
        <AirlinePNR>MWVGUH</AirlinePNR>              
        <TicketNo>5899553184514</TicketNo>              
        <FlightNumber>2704</FlightNumber>              
        <Origin>VTZ</Origin>              
        <Destination>MAA</Destination>              
        <DepartureDateTime>24/07/2012 19:15</DepartureDateTime>              
        <ArrivalDateTime>24/07/2012 21:00</ArrivalDateTime>              
        <AirCraftType>AT7</AirCraftType>              
        <CarrierCode>9W</CarrierCode>              
        <ClassCode>W</ClassCode>              
        <FareBasis>W2SA14JK</FareBasis>              
        <FrequentFlyerNumber />              
        <SpRequest />              
        <MealsPreference>VGML meals status : UN</MealsPreference>            
    </Item>            
    </SegmentInformation>        
</Item>      
  </TravellerInfo>  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:54:58+00:00Added an answer on June 7, 2026 at 3:54 am

    I think you should look at getChildNodes(). That will get you the immediate descendants of the node you call it on.

    You should then check each node in the resultant NodeList to determine it’s an <Item> (you’ll most likely get the text nodes inbetween elements etc. so checking is essential – see this SO answer and its question for more info)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to traverse each node of a tree efficiently without recursion in C (no
I have following code to traverse a tree (pre-order): public void traverse(Node node) {
How can I traverse an n -ary tree without using recursion? Recursive way: traverse(Node
When I try to traverse to the children of the gallery node, it return
Problem description: Read an xml file, traverse to a particular node (element), if it
I would like to traverse the HASH but one by one. Not in Random
is there a way to traverse an object to get the parent object data?
I'm building a spider which will traverse various sites and data mining them. Since
I have a graph which I traverse using a typical visitor pattern. I've run
I'm trying to traverse an XML document and select certain node attributes. The XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.