JMO9966
asked on
VB.Net XML document retrieve string function ?
Hello,
I'm using VB.Net to create an XML document that get's sent to an import program.
The import program will send me a ressponse back in this format:
'liine of code to generate response doc
strResponseDoc = xmlResponseDoc.OuterXml
'contents of strResponseDoc:
<JBXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<JBXMLRespond>
<JobAddRs ErrorCode="0" Message="">
<ID>3550</ID>
<LastUpdated>2007-08-06T14 :13:28</La stUpdated>
What I'm looking do to with VB is retrieve the message returned in double quotes on the third line of this sample response document, it there is an ErrorCode <> 0 there will be an error in this string that I need to retrieve.
Here's more of my code if needed.
strXmlRequestDoc = xmlRequestDoc.OuterXml
'Send XML to Import
response = jb.ProcessRequest(strXmlRe questDoc)
xmlResponseDoc = New XmlDocument
xmlRequestDoc = Nothing
'Set ID to the new job's ID.
xmlResponseDoc.LoadXml(res ponse)
strResponseDoc = xmlResponseDoc.OuterXml
As you can see strResponseDoc is where I need to retrieve this error messagef from.
Does VB have a way of doing so or will I need to create a function?
Thanks,
JMO9966
I'm using VB.Net to create an XML document that get's sent to an import program.
The import program will send me a ressponse back in this format:
'liine of code to generate response doc
strResponseDoc = xmlResponseDoc.OuterXml
'contents of strResponseDoc:
<JBXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<JBXMLRespond>
<JobAddRs ErrorCode="0" Message="">
<ID>3550</ID>
<LastUpdated>2007-08-06T14
What I'm looking do to with VB is retrieve the message returned in double quotes on the third line of this sample response document, it there is an ErrorCode <> 0 there will be an error in this string that I need to retrieve.
Here's more of my code if needed.
strXmlRequestDoc = xmlRequestDoc.OuterXml
'Send XML to Import
response = jb.ProcessRequest(strXmlRe
xmlResponseDoc = New XmlDocument
xmlRequestDoc = Nothing
'Set ID to the new job's ID.
xmlResponseDoc.LoadXml(res
strResponseDoc = xmlResponseDoc.OuterXml
As you can see strResponseDoc is where I need to retrieve this error messagef from.
Does VB have a way of doing so or will I need to create a function?
Thanks,
JMO9966
Will that document have more than one JobAddRs node that you have to parse?
I'm going to assume yes, because it doesn't make much difference to the code...
For Each xmlNode As XmlNode In xmlResponseDoc.SelectNodes ("//JobAdd Rs")
If CInt(xmlNode.Attributes("E rrorCode") .Value) <> 0 Then
Debug.WriteLine(xmlNode.At tributes(" Message"). Value)
End If
Next
For Each xmlNode As XmlNode In xmlResponseDoc.SelectNodes
If CInt(xmlNode.Attributes("E
Debug.WriteLine(xmlNode.At
End If
Next
ASKER
Thanks Paul, the document will always contain one JobAddRs node.
I will try that code right now.
Thanks again,
JMO9966
I will try that code right now.
Thanks again,
JMO9966
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.