Mega Code Archive

 
Categories / VB.Net / XML
 

XmlReader ReadContentAs reads the content as an object of the type specified

Imports System Imports System.IO Imports System.Xml Public Class Sample   Public Shared Sub Main()         Using reader As XmlReader = XmlReader.Create("data.xml")                    reader.ReadToDescendant("item")                    reader.MoveToAttribute("colors")           Dim colors As String() = CType(reader.ReadContentAs(GetType(String()), Nothing), String())           Dim color As String           For Each color In  colors             Console.WriteLine("Colors: {0}", color)           Next color                  End Using     End Sub End Class