Solved

Getting XML element's name

Posted on 2007-11-28
2
137 Views
Last Modified: 2010-03-30
Hi,

Getting a node like this:

    // Get child node.
    Node childNode = list.item(i);

How do you get the name of the element? For example:

    <furniture>chair</furniture>

I want to get the element name 'furniture'.

Thanks
0
Comment
Question by:DJ_AM_Juicebox
  • 2
2 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20371437
String name = childNode.getNodeName();
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 20371445
you're just interested in Element's so it would be something like:

if (childNode instanceof Element)


thers also a getNodeType() method for getting the type of the Node
The Node javadoc covers the different types
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Running Jira on Raspberry PI 2? 3 261
eclipse shortcuts 9 45
Windows 10 IE Certificate Issue 10 41
javap not working 8 36
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now