I am having a problem removing my <UserInfo> child node from this XML format. Can anyone please provide any suggestions? Thanks
regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
Code:
<?xml version="1.0"?>
<Locks>
<Filing FormType="FRI" FilingType="R" EndDate="1/1/2005" FirmId="0000173">
<UserInfo UserId="nfisbjg" Session="kvoyaz550ceqifm3btr5aoaf" />
<UserInfo UserId="nfisbjg" Session="234kjosdfoowaef" />
</Filing>
</Locks>
Code:
Public Sub DeleteUserFromFiling()
Dim xmlDocument As XmlDocument
xmlDocument = LoadXmlFile()
If ( Not xmlDocument Is Nothing ) Then
Dim xPathQuery As String
xPathQuery = "//Locks/Filing/UserInfo[@Session='" & m_SessionId & "']"
Dim xmlNode As XmlNode
xmlNode = xmlDocument.SelectSingleNode(xPathQuery)
'--------- PROBLEM IS HERE ------------
xmlDocument.DocumentElement.RemoveChild(xmlNode)
xmlDocument.RemoveChild(xmlNode)
Dim parentNode As XmlNode
parentNode = FindFilingByUserId(xmlDocument)
'Only remove the filing element if there are not any additional
'user session information appended as children to the filing element.
'This enables the filing to still be active when multiple browser
'sessions are timing out causing this routine to be called.
If parentNode.HasChildNodes = False Then
parentNode.RemoveAll()
End If
xmlDocument.Save(m_XmlFile)
End If
End Sub
regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.