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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Supra

    #1

    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.WriteConfigI nfo("User Modes", chkInvisible.Te xt,
    chkInvisible.Ch ecked, "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.DocumentEl ement).SelectSi ngleNode("/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.DocumentEl ement).SelectSi ngleNode("confi guration")
    ' remove the section
    node2.RemoveChi ld(node1)
    ElseIf aValue = "" Then
    ' find the section of this key
    node1 =
    (Doc.DocumentEl ement).SelectSi ngleNode("/configuration/" & aSection)
    ' return if the section doesn't exist
    If node1 Is Nothing Then Return True
    ' find the key
    node2 =
    (Doc.DocumentEl ement).SelectSi ngleNode("/configuration/" & aSection &
    "/" & aKey)
    ' return true if the key doesn't exist
    If node2 Is Nothing Then Return True
    ' remove the key
    If node1.RemoveChi ld(node2) Is Nothing Then Return False
    Else
    ' Both the Key and the Value are filled
    ' Find the key
    node1 =
    (Doc.DocumentEl ement).SelectSi ngleNode("/configuration/" & aSection &
    "/" & aKey) <======= error occured in here.
    If node1 Is Nothing Then
    ' The key doesn't exist: find the section
    node2 =
    (Doc.DocumentEl ement).SelectSi ngleNode("/configuration/" & aSection)
    If node2 Is Nothing Then
    ' Create the section first
    Dim e As Xml.XmlElement =
    Doc.CreateEleme nt(aSection)
    ' Add the new node at the end of the
    children of ("configuration ")
    node2 = Doc.DocumentEle ment.AppendChil d(e)
    ' return false if failure
    If node2 Is Nothing Then Return False
    ' now create key and value
    e = Doc.CreateEleme nt(aKey)
    e.InnerText = aValue
    ' Return False if failure
    If (node2.AppendCh ild(e)) Is Nothing Then
    Return False
    Else
    ' Create the key and put the value
    Dim e As Xml.XmlElement =
    Doc.CreateEleme nt(aKey)
    e.InnerText = aValue
    node2.AppendChi ld(e)
    End If
    Else
    ' Key exists: set its Value
    node1.InnerText = aValue
    End If
    End If
    ' Save the document
    Doc.Save(FileNa me)
    End Function

    regards,

  • Supra

    #2
    this is my xml file.........

    <configuratio n>
    -
    <PirateChat>
    <RealName>Pirat eChat XP Prof 2004 version 1.0 </RealName>
    <Email>supra@to yota.com</Email>
    <Nick>doremaf a</Nick>
    <AltNick>djanjo </AltNick>
    <Pswrd>supra</Pswrd>
    <Network>Undern et</Network>
    <Server>eu.unde rnet.org</Server>
    </PirateChat>
    </configuration>



    Supra wrote:
    [color=blue]
    > 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.WriteConfigI nfo("User Modes", chkInvisible.Te xt,
    > chkInvisible.Ch ecked, "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.DocumentEl ement).SelectSi ngleNode("/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.DocumentEl ement).SelectSi ngleNode("confi guration")
    > ' remove the section
    > node2.RemoveChi ld(node1)
    > ElseIf aValue = "" Then
    > ' find the section of this key
    > node1 =
    > (Doc.DocumentEl ement).SelectSi ngleNode("/configuration/" & aSection)
    > ' return if the section doesn't exist
    > If node1 Is Nothing Then Return True
    > ' find the key
    > node2 =
    > (Doc.DocumentEl ement).SelectSi ngleNode("/configuration/" & aSection &
    > "/" & aKey)
    > ' return true if the key doesn't exist
    > If node2 Is Nothing Then Return True
    > ' remove the key
    > If node1.RemoveChi ld(node2) Is Nothing Then Return
    > False
    > Else
    > ' Both the Key and the Value are filled
    > ' Find the key
    > node1 =
    > (Doc.DocumentEl ement).SelectSi ngleNode("/configuration/" & aSection &
    > "/" & aKey) <======= error occured in here.
    > If node1 Is Nothing Then
    > ' The key doesn't exist: find the section
    > node2 =
    > (Doc.DocumentEl ement).SelectSi ngleNode("/configuration/" & aSection)
    > If node2 Is Nothing Then
    > ' Create the section first
    > Dim e As Xml.XmlElement =
    > Doc.CreateEleme nt(aSection)
    > ' Add the new node at the end of the
    > children of ("configuration ")
    > node2 = Doc.DocumentEle ment.AppendChil d(e)
    > ' return false if failure
    > If node2 Is Nothing Then Return False
    > ' now create key and value
    > e = Doc.CreateEleme nt(aKey)
    > e.InnerText = aValue
    > ' Return False if failure
    > If (node2.AppendCh ild(e)) Is Nothing Then
    > Return False
    > Else
    > ' Create the key and put the value
    > Dim e As Xml.XmlElement =
    > Doc.CreateEleme nt(aKey)
    > e.InnerText = aValue
    > node2.AppendChi ld(e)
    > End If
    > Else
    > ' Key exists: set its Value
    > node1.InnerText = aValue
    > End If
    > End If
    > ' Save the document
    > Doc.Save(FileNa me)
    > End Function
    >
    > regards,[/color]


    Comment

    Working...