Mega Code Archive

 
Categories / VB.Net / XML LINQ
 

Create XDocument class with the specified content

Imports System Imports System.Xml Imports System.Xml.XPath Public Class MainClass     Public Shared Sub Main()         Dim srcTree As XDocument = _             <?xml version="1.0" encoding="utf-8" standalone="yes"?>                 <!--This is a comment-->                 <Root>                     <Child1>data1</Child1>                     <Child2>data2</Child2>                     <Child3>data3</Child3>                     <Info1>info1</Info1>                 </Root>         Dim doc As XDocument = _              <?xml version="1.0" encoding="utf-8" standalone="yes"?>                 <!--This is a comment-->                 <Root>                     <%= From el In srcTree.<Root>.Elements _                         Where CStr(el).StartsWith("data") _                         Select el %>                 </Root>         Console.WriteLine(doc)     End Sub End Class