Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Append Error

8 views
Skip to first unread message

sumi...@gmail.com

unread,
Oct 15, 2012, 10:00:44 PM10/15/12
to
Hello -

I have the following code and it works locally but when I publish it on the server it won't allow me to add new records. Is there anything I'm missing here. I just need to add more records to the XML file.

Dim strnum = GetRandom(0, 99999)
Dim xmlfile As New ConfigXmlDocument
xmlfile.Load(Server.MapPath("~\xmldata\survey.xml"))

Dim theSurveyTag As XmlElement = xmlfile.CreateElement("Survey")
Dim theTitleTag As XmlElement = xmlfile.CreateElement("Survey_Title")
Dim theLinkTag As XmlElement = xmlfile.CreateElement("Survey_Link")
Dim thePassTag As XmlElement = xmlfile.CreateElement("Survey_Pass")


Dim theNameText As XmlText = xmlfile.CreateTextNode(t1.Text)
Dim theEmailText As XmlText = xmlfile.CreateTextNode(t2.Text)
Dim theTelText As XmlText = xmlfile.CreateTextNode(t3.Text)


theTitleTag.AppendChild(theNameText)
theLinkTag.AppendChild(theEmailText)
thePassTag.AppendChild(theTelText)


theSurveyTag.SetAttribute("ID", strnum)
theSurveyTag.AppendChild(theTitleTag)
theSurveyTag.AppendChild(theLinkTag)
theSurveyTag.AppendChild(thePassTag)

xmlfile.DocumentElement.AppendChild(theSurveyTag)
xmlfile.Save(Server.MapPath("~\xmldata\survey.xml"))


Here is the existing XML output:

<?xml version="1.0" encoding="utf-8"?>
<Data>
<Survey ID="24949">
<Survey_Title>TEST</Survey_Title>
<Survey_Link>http://www.yahoo.com</Survey_Link>
<Survey_Pass>23</Survey_Pass>
</Survey>
<Survey ID="70480">
<Survey_Title>TEST</Survey_Title>
<Survey_Link>http://www.google.com</Survey_Link>
<Survey_Pass>35</Survey_Pass>
</Survey>
<Survey ID="60566">
<Survey_Title>TEST</Survey_Title>
<Survey_Link>http://www.google.com</Survey_Link>
<Survey_Pass>67</Survey_Pass>
</Survey>
</Data>
0 new messages