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 8790019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:32:51+00:00 2026-06-13T22:32:51+00:00

Now my software will show me (Root element: data) from xml file, but I

  • 0

Now my software will show me (Root element: data) from xml file, but I need list of nodes. This what Xml file have got for example:

(data have got “count” and “person”)

(count = 1)

(person have got “name” and “cars”)

(name = “Adam”)

(cars have got “Porshe” and “minimini”)

Softweare

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import java.io.File;
public void Ada()
{
File fXmlFile = new File("c:\\file.xml");
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);
            doc.getDocumentElement().normalize();

            System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
}

XML File:

<data>
    <count>1</count>
    <person>
        <name>Adam<name>
        <cars>
            <fast>Porshe</fast>
            <slow>MiniMini</slow>
        </cars>
    </person>
</data>
  • 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-13T22:32:52+00:00Added an answer on June 13, 2026 at 10:32 pm

    You can use:

    doc.getChildNodes()
    

    to get deeper and the recursively drill dow until there are no children left.

    It will return a NodeList you can the use the size() to ‘power’ a for loop.

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

Sidebar

Related Questions

I need to generate a unique code from a single PC, my software will
We have this software that has a webservices component. Now, the administrator of this
I'm in a bit of a situation right now. I need software that does
We need to write some software that will compile and run on both an
I'm really embarrassed to ask such a trivial question but debugging some software now
I am developing a software that will serve as back-end for a data-ware house,
I updated my phone software from 2.2 to 2.2.2 and now eclipse cannot see
Perhaps this is best asked on the wxPython mailing list, but I thought I'd
I want to build a software. This software will just get the path of
I've been a Software Developer now for over 10 years. I've mostly worked in

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.