A typo on my last post was pointed out to me, so I wanted to make note of it. This code:
Code:
alert_nodelist = alert_xmld.SelectNodes("/alerts/alert")
alert_status = alert_xmld.SelectNodes("/alerts/alert/status")
alert_state = alert_xmld.SelectNodes("/alerts/alert/state")
actually reads like this:
Code:
alert_nodelist = alert_xmld.SelectNodes("/alerts/alert")
alert_status = alert_xmld.SelectNodes("/alerts/alert/alertstatus")
alert_state = alert_xmld.SelectNodes("/alerts/alert/alertstate")
I had to change some of the node names for the post, and I forgot to change those ones. Anyway, I think that my problem lies in the call of the node. Here's what I've tried so far:
Using this:
Code:
strAlertStatus = alert_node.Attributes.GetNamedItem("status").Value
strAlertState = alert_node.Attributes.GetNamedItem("state").Value
results in the following error for the "strAlertStatus" node:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Using this:
Code:
strAlertStatus = alert_status.Attributes.GetNamedItem("status").Value
strAlertState = alert_state.Attributes.GetNamedItem("state").Value
results in the following error for the "strAlertStatus" node:
Compiler Error Message: BC30456: 'Attributes' is not a member of 'System.Xml.XmlNodeList'.
And using this:
Code:
strAlertStatus = aa_node.SelectSingleNode("//alertstatus/@status").Value
strAlertState = aa_node.SelectSingleNode("//alertstate/@state").Value
Results in the first nodeset being looped three times, which is the number of nodesets in the XML doc, like this:
*Page Properties*
strAlertStatus: closed
strAlertState: CO
*Page Properties*
strAlertStatus: closed
strAlertState: CO
*Page Properties*
strAlertStatus: closed
strAlertState: CO
I guess this could be progress, but I obviously don't know why it's not looping properly. So as you can see, I'm pretty lost on where to go from here. I'm really trying hard to solve this on my own, but I'd REALLY appreciate some help. Any suggestions would be greatly appreciated. Thanks.
KWilliams