Meaningless Drivel is fun!*
The moose likes XML and Related Technologies and the fly likes Access Xml node values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Access Xml node values" Watch "Access Xml node values" New topic
Author

Access Xml node values

kamal palia
Greenhorn

Joined: Jul 20, 2012
Posts: 17
<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

Joined: Sep 13, 2007
Posts: 1963
    
    7

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.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
kamal palia
Greenhorn

Joined: Jul 20, 2012
Posts: 17
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

Joined: Sep 13, 2007
Posts: 1963
    
    7

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

Joined: Jan 18, 2011
Posts: 464
    
    2
If you know getElementsByTagName well, you can continue to use one step further. Off-hand like this?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access Xml node values
 
Similar Threads
Need some help in setting up a url parameter into a form bean
Beans and Jsps and Servlets
Form Plugin Form Reference On Success callback
Unable to update database
how to enable a textarea in javascript?