johnjones2003
Programmer
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 "address" and "description" tags text will be received from text boxes.I tried the following code but to no avail.
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Xml" %>
</html>
<head>
<script runat="server">
Sub submit(sender As Object, e As EventArgs)
Dim writer As XmlTextWriter
writer = (C://temp/links.xml)
//Write the root element
writer.WriteStartElement("links"
//Write sub-elements
writer.WriteElementString("address", "link.Text"
writer.WriteElementString("description", "description.Text"
// 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="server">
<b>Enter the link:</b><asp:Textbox id=link runat="server"></asp:Textbox><br><br>
<b>Enter the description:</b><asp:Textbox id=description runat="server"></asp:Textbox><br><br>
<input type="submit" id="submit" runat="server">
</form>
</body>
</html>
Any advice or help would be great
thanks
john
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 "address" and "description" tags text will be received from text boxes.I tried the following code but to no avail.
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Xml" %>
</html>
<head>
<script runat="server">
Sub submit(sender As Object, e As EventArgs)
Dim writer As XmlTextWriter
writer = (C://temp/links.xml)
//Write the root element
writer.WriteStartElement("links"
//Write sub-elements
writer.WriteElementString("address", "link.Text"
writer.WriteElementString("description", "description.Text"
// 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="server">
<b>Enter the link:</b><asp:Textbox id=link runat="server"></asp:Textbox><br><br>
<b>Enter the description:</b><asp:Textbox id=description runat="server"></asp:Textbox><br><br>
<input type="submit" id="submit" runat="server">
</form>
</body>
</html>
Any advice or help would be great
thanks
john