• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DOM

 
kamiya sei
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the value of "node.getNodeName()"?
 
kamiya sei
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI , it's get first node in xml file. If find node equals("name"), display textcontent.

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you haven't actually examined its value?
 
kamiya sei
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic