Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating XML files using asp.net

Status
Not open for further replies.

johnjones2003

Programmer
Apr 19, 2003
1
IE
Hi, i was just looking for some advice on how to create simple xml files using asp.net. Is using XmlTextWriter
the best way to do this? I'm only a beginner programmer in asp.net so any help would be great. I want to create an xml file called links.xml with the following tags.

<links>
<address><description>Good search engine</description>
</links>

The &quot;address&quot; and &quot;description&quot; tags text will be received from text boxes.I tried the following code but to no avail.

<%@ import Namespace=&quot;System&quot; %>
<%@ import Namespace=&quot;System.IO&quot; %>
<%@ import Namespace=&quot;System.Xml&quot; %>

</html>
<head>
<script runat=&quot;server&quot;>
Sub submit(sender As Object, e As EventArgs)

Dim writer As XmlTextWriter
writer = (C://temp/links.xml)

//Write the root element
writer.WriteStartElement(&quot;links&quot;);

//Write sub-elements
writer.WriteElementString(&quot;address&quot;, &quot;link.Text&quot;);
writer.WriteElementString(&quot;description&quot;, &quot;description.Text&quot;);


// end the root element
writer.WriteEndElement();

//Write the XML to file and close the writer
writer.Close();

End Sub
</script>
</head>
<body bgColor=#00ffff>
<form runat=&quot;server&quot;>

<b>Enter the link:</b><asp:Textbox id=link runat=&quot;server&quot;></asp:Textbox><br><br>


<b>Enter the description:</b><asp:Textbox id=description runat=&quot;server&quot;></asp:Textbox><br><br>
<input type=&quot;submit&quot; id=&quot;submit&quot; runat=&quot;server&quot;>
</form>
</body>
</html>

Any advice or help would be great
thanks
john
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top