473,394 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

system error when writing to xml............

i got "system error" when saving to xml file.
i am using checkbox1 control to xml. when user clicked checkbox and set
to true and press btnOk to conform and save it to xml

rw.WriteConfigInfo("User Modes", chkInvisible.Text,
chkInvisible.Checked, "PirateChat.xml")

the error occured in hightleighted in below :.......

Public Function WriteConfigInfo(ByVal aSection As String, ByVal aKey As
String, ByVal aValue As String) As Boolean
Dim node1 As XmlNode
Dim node2 As XmlNode
If aKey = "" Then
' find the section, remove all its keys and remove
the section
node1 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection)
' if no such section, return True
If node1 Is Nothing Then Return True
' remove all its children
node1.RemoveAll()
' select its parent ("configuration")
node2 =
(Doc.DocumentElement).SelectSingleNode("configurat ion")
' remove the section
node2.RemoveChild(node1)
ElseIf aValue = "" Then
' find the section of this key
node1 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection)
' return if the section doesn't exist
If node1 Is Nothing Then Return True
' find the key
node2 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection &
"/" & aKey)
' return true if the key doesn't exist
If node2 Is Nothing Then Return True
' remove the key
If node1.RemoveChild(node2) Is Nothing Then Return False
Else
' Both the Key and the Value are filled
' Find the key
node1 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection &
"/" & aKey) <======= error occured in here.
If node1 Is Nothing Then
' The key doesn't exist: find the section
node2 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection)
If node2 Is Nothing Then
' Create the section first
Dim e As Xml.XmlElement =
Doc.CreateElement(aSection)
' Add the new node at the end of the
children of ("configuration")
node2 = Doc.DocumentElement.AppendChild(e)
' return false if failure
If node2 Is Nothing Then Return False
' now create key and value
e = Doc.CreateElement(aKey)
e.InnerText = aValue
' Return False if failure
If (node2.AppendChild(e)) Is Nothing Then
Return False
Else
' Create the key and put the value
Dim e As Xml.XmlElement =
Doc.CreateElement(aKey)
e.InnerText = aValue
node2.AppendChild(e)
End If
Else
' Key exists: set its Value
node1.InnerText = aValue
End If
End If
' Save the document
Doc.Save(FileName)
End Function

regards,

Jul 21 '05 #1
1 1682
<configuration>
-
<PirateChat>
<RealName>PirateChat XP Prof 2004 version 1.0 </RealName>
<Email>su***@toyota.com</Email>
<Nick>doremafa</Nick>
<AltNick>djanjo</AltNick>
<Pswrd>supra</Pswrd>
<Network>Undernet</Network>
<Server>eu.undernet.org</Server>
</PirateChat>
</configuration>

Supra wrote:
i got "system error" when saving to xml file.
i am using checkbox1 control to xml. when user clicked checkbox and
set to true and press btnOk to conform and save it to xml

rw.WriteConfigInfo("User Modes", chkInvisible.Text,
chkInvisible.Checked, "PirateChat.xml")

the error occured in hightleighted in below :.......

Public Function WriteConfigInfo(ByVal aSection As String, ByVal aKey
As String, ByVal aValue As String) As Boolean
Dim node1 As XmlNode
Dim node2 As XmlNode
If aKey = "" Then
' find the section, remove all its keys and remove
the section
node1 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection)
' if no such section, return True
If node1 Is Nothing Then Return True
' remove all its children
node1.RemoveAll()
' select its parent ("configuration")
node2 =
(Doc.DocumentElement).SelectSingleNode("configurat ion")
' remove the section
node2.RemoveChild(node1)
ElseIf aValue = "" Then
' find the section of this key
node1 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection)
' return if the section doesn't exist
If node1 Is Nothing Then Return True
' find the key
node2 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection &
"/" & aKey)
' return true if the key doesn't exist
If node2 Is Nothing Then Return True
' remove the key
If node1.RemoveChild(node2) Is Nothing Then Return
False
Else
' Both the Key and the Value are filled
' Find the key
node1 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection &
"/" & aKey) <======= error occured in here.
If node1 Is Nothing Then
' The key doesn't exist: find the section
node2 =
(Doc.DocumentElement).SelectSingleNode("/configuration/" & aSection)
If node2 Is Nothing Then
' Create the section first
Dim e As Xml.XmlElement =
Doc.CreateElement(aSection)
' Add the new node at the end of the
children of ("configuration")
node2 = Doc.DocumentElement.AppendChild(e)
' return false if failure
If node2 Is Nothing Then Return False
' now create key and value
e = Doc.CreateElement(aKey)
e.InnerText = aValue
' Return False if failure
If (node2.AppendChild(e)) Is Nothing Then
Return False
Else
' Create the key and put the value
Dim e As Xml.XmlElement =
Doc.CreateElement(aKey)
e.InnerText = aValue
node2.AppendChild(e)
End If
Else
' Key exists: set its Value
node1.InnerText = aValue
End If
End If
' Save the document
Doc.Save(FileName)
End Function

regards,

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
5
by: Burton Roberts | last post by:
This is also posted in the security newsgroup. Sorry for cross-posting, but I'm desperate. I have a Winforms application in VB.NET with a SQL Server (MSDE) backend. In the root application...
8
by: José Achig | last post by:
Hi I have to use functions inside of system apis so I want the correct dllimports declarations in c# for the following functions or information about where I can get these statements. +...
5
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because...
4
by: 101 | last post by:
I get a security error when trying to write out to an XMLSchema file "myDs.WriteXmlSchema(strXMLSchemaFile)". I am running XP SP2, No Domain, MS file and print sharing uninstalled. I was able to...
11
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very...
14
by: prasadjoshi124 | last post by:
Hi All, I am writing a small tool which is supposed to fill the filesystem to a specified percent. For, that I need to read how much the file system is full in percent, like the output given...
0
by: jammendolia | last post by:
Hello all, I am having an intermittent exception occur when writing the the eventlog from a windows service application written in c#, running on a Win2k SP4 server. Here's the code: ...
2
by: Nelly78 | last post by:
Hi All, I have a situtation my application is running on windows 2003 server which is a domain and in web.config <Identity impersonation=true username=ABC\XYZ password=******> what i am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.