Print Page | Close Window

append to XML file

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7529
Printed Date: 29 March 2026 at 1:24pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: append to XML file
Posted By: Mart
Subject: append to XML file
Date Posted: 23 November 2003 at 11:54am

Hi i have made the following code, but it doesnt work no error it just doesnt add it. Its proabably really simple but i cant get my head around it

Dim pass As String = p1.Text

Dim user As String = username.Text

Dim hashedpass As String

Dim XMLdoc As New XmlDocument

Dim ConfigFile As String = Server.MapPath("/auth/users.Config")

Dim elem As XmlElement = XMLdoc.CreateElement(user)

 

hashedpass = FormsAuthentication.HashPasswordForStoringInConfigFile(pass, "MD5")

XMLdoc.Load(ConfigFile)

Dim elemPass As XmlElement = XMLdoc.CreateElement("pass")

elemPass.InnerText = pass

elem.AppendChild(elemPass)

Dim elemreturn As XmlElement = XMLdoc.CreateElement("return")

elemreturn.InnerText = "userdetails.aspx"

elem.AppendChild(elemreturn)

Dim elemname As XmlElement = XMLdoc.CreateElement("fullname")

elemname.InnerText = fullname.Text

elem.AppendChild(elemname)

Dim elememail As XmlElement = XMLdoc.CreateElement("email")

elememail.InnerText = email.Text

elem.AppendChild(elemname)

Dim elemRole As XmlElement = XMLdoc.CreateElement("role")

elemRole.InnerText = "user"

elem.AppendChild(elemRole)

 

XMLdoc.Save(ConfigFile)

Response.Redirect("default.aspx?user=" & user, True)




Any ideas?
Thanks, Mart.




Replies:
Posted By: Diep-Vriezer
Date Posted: 23 November 2003 at 3:22pm
 Not really. Maybe you should rewrite the code, sometimes that'll work for me.

-------------
Gone..


Posted By: Mart
Date Posted: 24 November 2003 at 10:42am
Thanks, i just did that and it works now.


Posted By: Diep-Vriezer
Date Posted: 28 November 2003 at 12:58am

Wait, the code above does contains some errors:

Dim elemname As XmlElement = XMLdoc.CreateElement("fullname")

elemname.InnerText = fullname.Text

elem.AppendChild(elemname)

Dim elememail As XmlElement = XMLdoc.CreateElement("email")

elememail.InnerText = email.Text

elem.AppendChild(elemname)

Anyway, if it works now, that's great!



-------------
Gone..


Posted By: Mart
Date Posted: 28 November 2003 at 9:27am
This is the code i used:


Dim account As XmlElement = XMLdoc.CreateElement("account")

         &nbs p;      Dim nextnode As XmlNode
         &nbs p;      nextnode = XMLdoc.LastChild

         &nbs p;      nextnode.AppendChild(account)

         &nbs p;      Dim UserNameEle As XmlElement = XMLdoc.CreateElement("user")
         &nbs p;      UserNameEle.InnerText = user
         &nbs p;      account.AppendChild(UserNameEle)

         &nbs p;      Dim UserPass As XmlElement = XMLdoc.CreateElement("pass")
         &nbs p;      UserPass.InnerText = hashedpass
         &nbs p;      account.AppendChild(UserPass)

         &nbs p;      Dim UsersName As XmlElement = XMLdoc.CreateElement("fullname")
         &nbs p;      UsersName.InnerText = fullname.Text
         &nbs p;      account.AppendChild(UsersName)

         &nbs p;      Dim UsersEmail As XmlElement = XMLdoc.CreateElement("email")
         &nbs p;      UsersEmail.InnerText = email.Text
         &nbs p;      account.AppendChild(UsersEmail)

         &nbs p;      Dim role As XmlElement = XMLdoc.CreateElement("role")
         &nbs p;      role.InnerText = "user"
         &nbs p;      account.AppendChild(role)

         &nbs p;      Dim active As XmlElement = XMLdoc.CreateElement("active")
         &nbs p;      active.InnerText = "1"
         &nbs p;      account.AppendChild(active)


         &nbs p;      XMLdoc.Save(ConfigFile)



Posted By: Mart
Date Posted: 28 November 2003 at 9:28am
Sorry about the formatting wwf and mozilla firebird don't mix



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net