Mega Code Archive

 
Categories / VB.Net / XML LINQ
 

Create XDocument with hard code string

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>                     <Info8>info8</Info8>                 </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