Mega Code Archive

 
Categories / VB.Net / XML LINQ
 

XDocument Load(String, LoadOptions) creates a new XDocument from a file, optionally preserving white space

Imports System Imports System.Xml Imports System.Xml.XPath Public Class MainClass     Public Shared Sub Main()         Dim doc1 As XDocument = XDocument.Load("data.xml", LoadOptions.None)         Console.WriteLine("nodes if not preserving whitespace: {0}", doc1.DescendantNodes().Count())                  Dim doc2 As XDocument = XDocument.Load("data.xml", LoadOptions.PreserveWhitespace)         Console.WriteLine("nodes if preserving whitespace: {0}", doc2.DescendantNodes().Count())     End Sub End Class