These tutorials demonstrate selected features in ASP.NET version 2.0, but they are compatible with later versions of ASP.NET as well. For the current documentation, see the ASP.NET portal on the MSDN Web site.

 

 

   Welcome   |   ASP.NET   |   Web Services   |   Class Browser   
  |   I want my samples in...      

How Do I...? Common Tasks QuickStart Tutorial

How Do I...Read and Write XML?

This sample illustrates how data can be streamed between components. XML data is parsed by using the XmlReader, and then written out by using the XmlWriter.

VB XMLReadWrite.exe
View Source

The following code reads the book price, calculates a discounted price, and then writes a price element that includes the original and discounted prices.

		
Dim originalPrice As Double = 0.0
originalPrice = reader.ReadElementContentAsDouble()
...
Dim discountedPrice As Double = originalPrice - originalPrice * 0.25
writer.WriteStartElement("price")
writer.WriteAttributeString("alternative", "25% discount")
writer.WriteAttributeString("originalPrice", originalPrice.ToString())
writer.WriteValue(discountedPrice)
writer.WriteEndElement()
VB




Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.