I'm having an XML sting looking like this:
<?xml version="1.0" encoding="UTF-8"?>
<SR Workstation="0014" Status="Active">
<OS>
<Identification Hardware="DELL" SerialNumber="123456789">Confirmed</Identification>
<CN> EXTERN</CN>
<CV>1.1.2.45</CV>
<TS>Idle</TS>
<TSS>Ok</TSS>
<ReaderStatus Reader="Icc">Enabled</ReaderStatus>
<ReaderStatus Reader="MS">Enabled</ReaderStatus>
<LPS>Unavailable</LPS>
</OS>
</SR>
I can get the Workstation data and the Status Data with this script in VB.net
Dim sr As New System.IO.StringReader(l_Result.XMLData)
Dim doc As New Xml.XmlDocument
doc.Load(sr)
Dim reader As New Xml.XmlNodeReader(doc)
While reader.Read()
Select Case reader.NodeType
Case Xml.XmlNodeType.Element
If reader.Name = "SR" Then
If reader.GetAttribute("WorkStation") = "0014" Then
txtStatus.Text = reader.GetAttribute("Status")
txtSerial.Text = reader.GetAttribute("Identification/SerialNumber")
txtHardware.Text = reader.GetAttribute("Identification/Hardware")
lblConfirmed.Text = reader.GetAttribute("Identification")
End If
End If
End Select
End While
But getting the values 123456789 (SerialNumber), DELL (Hardware) and Confirmed isn't working.
Can someone help me? I aint getting errors but my textboxes and label remain empty.
XmlNodeReader(I much preferSystem.Xml.Linq.XDocument) but I have a feeling you cannot attempt to traverse to a child node's attribute that way. Or, if you can, you would need to include "OS" in the path to "Identification".