Hello,
I have the following XML file (condensed)
I need to add an new User child element. I cannot seem to get it to work. Here is the code I am using.
When I run this I get an error "Operation is not valid due to the current position of the navigator." Is the navigator not moving? I have no idea what the problem is. I am new to XML so any help is appreciated.
Thnaks in advance.
I have the following XML file (condensed)
Code:
<FileZillaServer>
<Users>
</User>
<User Name="SandmanMotel">
<Option Name="Pass">5f4dcc3b5aa765d61d8327deb882cf99</Option>
<Option Name="Group"/>
<Option Name="Bypass server userlimit">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="IP Limit">0</Option>
<Option Name="Enabled">1</Option>
<Option Name="Comments"/>
<Option Name="ForceSsl">0</Option>
<IpFilter>
<Disallowed/>
<Allowed/>
</IpFilter>
<Permissions>
<Permission Dir="E:\Customer FTP\Sandman Motel">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">0</Option>
<Option Name="FileAppend">1</Option>
<Option Name="DirCreate">1</Option>
<Option Name="DirDelete">0</Option>
<Option Name="DirList">1</Option>
<Option Name="DirSubdirs">1</Option>
<Option Name="IsHome">1</Option>
<Option Name="AutoCreate">0</Option>
</Permission>
</Permissions>
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="0" UlType="0" UlLimit="10" ServerUlLimitBypass="0">
<Download/>
<Upload/>
</SpeedLimits>
</User>
</Users>
</FileZillaServer>
I need to add an new User child element. I cannot seem to get it to work. Here is the code I am using.
Code:
Dim document As XmlDocument = New XmlDocument()
document.Load("c:\XML\FileZilla Server.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()
navigator.MoveToChild("FileZillaServer", Nothing)
navigator.MoveToChild("Users", Nothing)
MsgBox(navigator.LocalName)
navigator.InsertAfter("<User></User>")
Console.WriteLine(navigator.OuterXml)
Thnaks in advance.