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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't read XML

Status
Not open for further replies.

JimmyFo

Programmer
Feb 14, 2005
102
US
Hi, I can't access the following XML structure - it never goes into the if statement. The Web.Config I am accessing is well formed and this is the structure.

Ideas why?

Code:
        Dim doc As XmlDocument = New XmlDocument()
        doc.Load("C:\Documents and Settings\Code2\ProjectManagement\Web.config")
        Dim node As XmlNode = doc.SelectSingleNode("/configuration/system.web/authorization/allow")
        If TypeOf node Is XmlElement Then
            Dim add As XmlElement = CType(node, XmlElement)
            add.SetAttribute("value", "Your Value")
        End If

Thanks,
James
 
At first glance I'd say it's because your variable "node" is declared as a type XmlNode. If it is an XmlNode, it can't be an XmlElement as well...


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
I changed it to XMLNode and it still skips the if statement; when I change to the "allow" node and try to get attribute count/anything it says that Object Not Set to Reference. Ideas?

thanks,
James
 
That's the problem - is there something wrong with this statement? How come it claims it isn't valid?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top