Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read this kind of xml file?

 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know to read a simple xml file in the below format

http://www.developerfusion.com/code/2064/a-simple-way-to-read-an-xml-file-in-java/

i want to know how do i read the xml if it is of the below format.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48957
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for us beginners. Moving.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "this kind", do you mean the attributes? If so, check out the DOM methods Node.getAttributes and Element.getAttribute.
 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
like there are several attributes inside the same DESPROXY tag.

so how would i do that?

because in my case there are several key-value pairs.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:check out the DOM methods Node.getAttributes and Element.getAttribute.
 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


my xml is as follows..


i do not know and understand how to read the values in DESPROXY element
that is "N" "100" and other values .
please anyone can help me?
 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am getting a nullpointerException because it is not reading the values?

what should be my next step?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J radolf wrote:am getting a nullpointerException because it is not reading the values?

what should be my next step?


Reading the responses from Ulf and David would probably be a good first step.
 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

By "this kind", do you mean the attributes? If so, check out the DOM methods Node.getAttributes and Element.getAttribute.



where do i put these methods in my code? after DESPROXY tag value returns?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J radolf wrote:where do i put these methods in my code? after DESPROXY tag value returns?


Well, they are methods of the Node and Element classes, so you will need an instance of one of these classes in order to call them.
Find out where in your code you have these instances and then experiment with calls to these methods and see what data they return.
 
J radolf
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys.

Finally i solved it.

Thanks Everyone.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic