I have a function that gets string close to it. While testing the function, I get an empty reference exception on the string parameter which gets passed, even though the string is not zero, I do not understand why I'm getting this error. I have a screen shot
Both a dummy value I used The string parameter in the selectSingleNode function and the new value string parameter is my funk I have been sent to the screen and both of them include the value, so I do not understand why this is leaving an empty reference exception. For clarity, the purpose of the function is to write back values to the nodes of the XML file.
UPDATE
Sorry for not posting code
Private sub set val (string, as a vault nodo mode, string As new value) "write XML config file test dummy string like string =" config / "& amp; NodoteMode is using the XML XML as XML XML newcast FS filestream = new filestream (HTTPCTXContentSERR.mappath ("~ / XML / Config / Config .xml"), file MOD.Open, FileAccess, RedWrite , FileShare. RedWrite) XMLDec Dim foo as Load (FS) XMLNode = xmlDoc.SelectSingleNode (Dummy) Console WrititeLine (foo.InnerXml) fs.Seek (0, SeekOrigin.Begin) fs.SetLength (0) xmlDoc.Save (fs) end is used to end end
and here is the XML file I
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; I am working with & Lt; Config xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http://www.w3.org/2001/XMLSchema" & gt; & Lt; Username & gt; John.doe@email.com< / User Name & gt; & Lt; Password & gt; Password1 & lt; / Password & gt; & Lt; ProductType & gt; MyProduct & lt; / ProductType & gt; & Lt; DirectoryEntryPath & gt; LDAP: // mydomain & lt; / DirectoryEntryPath & gt; & Lt; SMTPDefaultOnly & gt; This is true & lt; / SMTPDefaultOnly & gt; & Lt; Logo & gt; MyLogo.gif & lt; / Logo & gt; & Lt; / Config & gt; Yes, the SlectSingleNode function is not returning a value; I just started working with XPath, it seemed like I was not sure when I was using last week. That's why he stopped working now.
UPDATE2:
Understand, set the stupid mistake set method ("username", value.ToString), set _userName = value End Set (byVal value as string) method Was passed as "UserName" instead of "username".
The blank reference is the result SelectSingleNode This is, when xpath is assessed by inserting / config /
and the contents of the nodemod
are documented Is not a node match. So you get zero, and the attempt to clear the intrate
gives an exception.
We will actually need to look at the nodetomod
and the XML file further to help, besides, please post the code instead of screenshots!
Comments
Post a Comment