Solved

Getting XML element's name

Posted on 2007-11-28
2
135 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

706 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

18 Experts available now in Live!

Get 1:1 Help Now