Solved

Getting XML element's name

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nextBoolean(double p) for Random class 3 41
factorial example 4 49
servlet filter example 37 72
java mysql insert application 14 29
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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.

831 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