Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

obtaining field values from xmldocument

Status
Not open for further replies.

JABOSL

Programmer
Jan 25, 2006
35
I've got a xml file I receive as one long string. I use:

Dim doc As New XmlDocument
doc.LoadXml(xmlString)

I can't figure out how to see the values of the fields that have been passed to me. For instance how would I put the account_number or better yet the reply_code into a textbox? (I manually broke the xml string into lines below to make it easier to see where what I'm asking for exists.) Thanks!

<?xml version="1.0" encoding="UTF-8"?>
<status_request>
<session_key>EdUEGY8WE=</session_key>
<message_type>0200</message_type>
<transaction_type>01</transaction_type>
<sequence_number>000001</sequence_number>
<data_indicator>1</data_indicator>
<addenda_indicator>1</addenda_indicator>
<account_number>10362940764</account_number>
<response_fields>
<reply_code>050</reply_code>
<auth/>
<reference_no/>
</response_fields>
</cardtel_request>
 
JABOSL,

In order to correctly do it in VB.NET, the sending of XML file should be implemented through the object serialization, not as a one long string.
Look at the SoapFormatter and FileStream objects for your task.

vladk

 
I don't send it, it comes from another company. I get it with the following command which passes a request string to them.

Code:
xmlReply = proxy.validate(requestMsg)

It looks like the answer to my question would be.

Code:
Dim doc As New XmlDocument
doc.LoadXml(xmlReply)

Dim actNbr As XmlNodeList = doc.GetElementsByTagName("account_number")
Dim replyCode As XmlNodeList = doc.GetElementsByTagName("reply_code")

MessageBox.Show("Account: " & actNbr(0).InnerText)
MessageBox.Show("Reply code: " & replyCode(0).InnerText)
If anyone knows of a better way let me know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top