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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:48:21+00:00 2026-06-06T05:48:21+00:00

To set the scene, I’m currently working on an XML adapter for Android that

  • 0

To set the scene, I’m currently working on an XML adapter for Android that will read in the XML files I’ve been given and parse them into a database. I thought I had this down until they sprung on me that the nodes in the XML file could change from file to file, and so I need to build in a mechanism to cope with missing variables.

The most obvious solution to this was a switch() statement, but that won’t work with strings, so I started building an if-then-else structure. The idea was that it would check the name of the node and work out what to do with it based on that. Simple, no?

The problem is, I can’t seem to pull the name of the nodes I need from the XML file no matter what I do. The structure of the XML file is below:

<Vehicle>
    <Detail>
        <VIN>BBB2791276393</VIN>
        <RegNo>KN05EAP</RegNo>
        <Doors>5</Doors>
    </Detail>
</Vehicle>

What I need to be able to compare against is tag names like “VIN” or “RegNo”, but I can’t figure out a way to pull them out. ETA: As I didn’t make this clear, the child nodes of Detail change between XML files, and I have to deal with them as they come…

I’m using a DOM parser, and pulling out a NodeList based on <Detail>. NodeList.item(0) gives me the <Detail> node, but if I then try and break that down (with getChildNodes() for example), I can’t get the tag names for <VIN> or <RegNo>. In fact, I can’t seem to get any kind of reference for them that I could use to determine what node it is based on the original name.

Anyone got any ideas?

  • 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-06T05:48:24+00:00Added an answer on June 6, 2026 at 5:48 am

    Ok..as you explained that you can reach up to Detail tag..try doing it this way…

    // Getting VIN of Detail
     if (element.getElementsByTagName("VIN").getLength() > 0) {
            childNode = element.getElementsByTagName("VIN").item(0); //Get all the elements one by one
            String VIN = childNode.getFirstChild().getNodeValue();
    
        }
    

    You can do it for all the children tags of Detail…Hope this will help you..!!!

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

Sidebar

Related Questions

Let me set the scene: I'm a PHP developer that needs to take info
I will try and set the scene as best i can. *lights candle What
I set up my scene (Android app, OpenGL ES) like this: GLU.gluPerspective(gl, 60, viewRatio,
Let me set the scene.. You can open files in a specific mode like
I'll set the scene first... We use Subversion and currently have a reasonably large
Just wonder what is behind the scene. Actually it seems that we can set
I have an ImageView on my scene that I would like to set the
I wanna set My Scene Background but I don't know how! I had read
This is maybe unusual so let me set the scene: We have an SVN
I have a 2D scene, 2 textures set as render targets, and a vertex

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.