Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access Xml node values

 
kamal palia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<form action="http://localhost:7003/MultiMPI/Authenticate" method="post">
<textarea name="xmlData" cols=90 rows=90>
<req-auth>
<request-id>4sS4yV6tQ2</request-id>
<response-id>MTQ0NzY2</response-id>
<req-type>1002</req-type>
<auth-data>
<field name='OTP2' value='360055' />
</auth-data>
</req-auth>
</textarea>
<br><input type="submit" value="Request">
</form>



how can i get value 360055?
 
K. Tsang
Bartender
Posts: 3440
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using XSLT surely able to get the necessary values. However, does your form data follow a DTD or XML Schema? With such doc you can jump to the node or tag you need.
 
kamal palia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to access all the nodes value by using

NodeList requestID = element.getElementsByTagName("request-id");
Element line = (Element) requestID.item(0);

but using same how can i get the value of

<auth-data>
<field name='OTP2' value='360055' />
</auth-data>

360055?
 
K. Tsang
Bartender
Posts: 3440
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so what element are you on, <auth-data> or <field>? The actual value you need is in the field element with the attribute "value".

You may want to check out this link which is similar to what you should be getting at.
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know getElementsByTagName well, you can continue to use one step further. Off-hand like this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic