[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Getting XML element's name

Posted on 2007-11-28
2
Medium Priority
?
164 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 2000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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 …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 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