digitaldrew
Well-known member
- Joined
- Nov 10, 2012
- Messages
- 167
- Programming Experience
- Beginner
Hey everyone..I have an XML file which contains three different domains in it. What I am trying to do is read the Descendants portion to find a specific code. If that code is "200" then I want to pull the innertext between the >< of that node. I'm about to read the descendants just fine but I'm having problems getting the innertext of that same node..
Here is what the XML would look like
and here is my code so far..
As you can see above..when the attribute equals 200 such as the first domain node in my example..I then want it to pull the <domain></domain> innertext..Otherwise, if it throws something else such as 506 in my second example - it will do something else..
Here is what the XML would look like
HTML:
<?xml version="1.0" encoding="UTF-8"?>
<Transaction>
<request>check</request>
<ip>192.168.0.1</ip>
<domain code="200">ABC.com</domain>
<domain code="506">BCD.com</domain>
</Transaction>
and here is my code so far..
VB.NET:
Dim XML_Code As String = checkResponse
Dim document As XDocument = XDocument.Parse(XML_Code)
Dim my_domains = document.Descendants("Transaction").Descendants("domain")
If my_domains.Count > 0 Then
For Each my_domain As XElement In my_domains
If my_domain.Attribute("code").Value = 200 Then
'HERE IS WHERE I WANT TO GET THE INNERTEXT OF THAT NODE
Else
'do something else
End If
Next
End If
As you can see above..when the attribute equals 200 such as the first domain node in my example..I then want it to pull the <domain></domain> innertext..Otherwise, if it throws something else such as 506 in my second example - it will do something else..