This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes DOM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "DOM" Watch "DOM" New topic
Author

DOM

kamiya sei
Greenhorn

Joined: Dec 12, 2012
Posts: 25
HI.
The following is a small snippet of my application. When I run, it doesn't display "name". Why ???

here is my code .

if (node.getNodeName().equals("name")) {

String str = node.getTextContent();

System.out.println("Student name " + str);
}

and file xml

<Student>
<name>Kamiya Sei</name>
<mark>30</mark>
</Student>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41125
    
  45
What is the value of "node.getNodeName()"?


Ping & DNS - my free Android networking tools app
kamiya sei
Greenhorn

Joined: Dec 12, 2012
Posts: 25
HI , it's get first node in xml file. If find node equals("name"), display textcontent.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41125
    
  45
But you haven't actually examined its value?
kamiya sei
Greenhorn

Joined: Dec 12, 2012
Posts: 25
Ulf Dittmer wrote:But you haven't actually examined its value?


I don't understand what you mean.

So, I want to show data in xml file using DOM, how to repair this code ??? Please !
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41125
    
  45
Have you ever printed out the actual value of "node.getNodeName()"? You assume what it is, but it's better to ensure that it actually is what you think it is.

By the way, there's no point in quoting a previous message if you're the next one to reply - it is assumed that that's what you're referring to.
kamiya sei
Greenhorn

Joined: Dec 12, 2012
Posts: 25
Ulf Dittmer wrote:Have you ever printed out the actual value of "node.getNodeName()"? You assume what it is, but it's better to ensure that it actually is what you think it is.

By the way, there's no point in quoting a previous message if you're the next one to reply - it is assumed that that's what you're referring to.



Ok. I will check my code again . Maybe, I have mistake in this code. Thanks you !
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: DOM
 
Similar Threads
Another "Fantastic" Static Method Problem I need help on...
XSLT Calculations
Arrays in Hashtable
how to retrieve value of attribute of an xml element tag using jsp
Inheritance