Use XMLTextWriter to create XML file (VB.net) : XMLTextWriter « XML « ASP.NET Tutorial

Home
ASP.NET Tutorial
1.ASP.Net Instroduction
2.Language Basics
3.ASP.net Controls
4.HTML Controls
5.Page Lifecycle
6.Response
7.Collections
8.Validation
9.Development
10.File Directory
11.Sessions
12.Cookie
13.Cache
14.Custom Controls
15.Profile
16.Configuration
17.LINQ
18.ADO.net Database
19.Data Binding
20.Ajax
21.Authentication Authorization
22.I18N
23.Mobile
24.WebPart
25.XML
ASP.NET Tutorial » XML » XMLTextWriter 
25.16.1.Use XMLTextWriter to create XML file (VB.net)
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Xml" %>

<script runat=server>
   sub Page_Load(Sender as Object, e as EventArgs)
      dim writer as XMLTextWriter
         
      try
         writer = new XMLTextWriter(Server.MapPath("Data.xml"), nothing)
         
         writer.WriteStartDocument
         writer.Formatting = Formatting.Indented
         writer.Indentation = 3
         writer.WriteStartElement("bookstore")
         writer.WriteStartElement("book")
         writer.WriteAttributeString("genre""history")
         writer.WriteElementString("title""my title")
         writer.WriteElementString("price","6.99")
         writer.WriteStartElement("author")
         writer.WriteElementString("first-name","M")
         writer.WriteEndElement()
         writer.WriteEndElement()
         writer.WriteEndElement()
         writer.Flush
      catch ex as Exception
         Response.Write("Error accessing XML file")
      finally
         writer.Close
         Response.Write("Finished processing")
      end try
   end sub
</script>

<html><body>

</body></html>
25.16.XMLTextWriter
25.16.1.Use XMLTextWriter to create XML file (VB.net)
25.16.2.Use XmlTextWriter to create XML document, then use XmlTextReader to read it back
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.