aspose file tools*
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 Spring in Action this week in the Spring 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: 42280
    
  64
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: 42280
    
  64
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: 42280
    
  64
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 !
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: DOM