Create XDocument class with the specified XDeclaration and content. : XDocument « XML LINQ « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net » XML LINQ » XDocumentScreenshots 
Create XDocument class with the specified XDeclaration and content.
 

Imports System
Imports System.IO

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>
                    <Child2>data4</Child2>
                    <Info5>info5</Info5>
                    <Info6>info6</Info6>
                    <Info7>info7</Info7>
                    <Info8>info8</Info8>
                </Root>
        Dim doc As XDocument = _ 
            <?xml version="1.0" encoding="utf-8" standalone="yes"?>
                <!--This is a new comment-->
                <Root>
                    <%= From el In srcTree.<Root>.Elements _
                        Where CStr(el).StartsWith("data"_
                        Select el %>
                </Root>
        doc.Save("Test.xml")
        Console.WriteLine(File.ReadAllText("Test.xml"))
    End Sub
End Class

   
  
Related examples in the same category
1.Add element to XDocument
2.Create new Xml document with XDocument and XElement
3.Create an in-memory XML document with XDocument
4.Create XDocument from XmlReader
5.Get Xml encoding from XDocument
6.Load the Employees.xml and store the contents into an XDocument object
7.Get version from XDocument
8.Reading Rss feed with XDocument
9.Display the XML files declaration information with an XDocument object
10.Display the name of the root element in the loaded XML tree
11.Is Xml standalone
12.LocalName returns the name of the element as a string
13.Name property returns the XName class
14.XDocument Class represents an XML document.
15.Create XDocument class with the specified content.
16.Create XDocument class.
17.Create XDocument with hard code string
18.XDocument.Declaration Property gets or sets the XML declaration for this document.
19.XDocument.DocumentType Property gets the Document Type Definition (DTD) for this document.
20.XDocument.Load (String) creates a new XDocument from a file.
21.XDocument.Load(String, LoadOptions) creates a new XDocument from a file, optionally preserving white space
22.XDocument.Load (TextReader) creates a new XDocument from a TextReader.
23.XDocument.Load (TextReader, LoadOptions)
24.XDocument.NodeType Property gets the node type for this node.
25.XDocument.Parse creates a new XDocument from a string.
26.XDocument.Parse Method creates a new XDocument from a string, optionally preserving white space
27.XDocument.Root Property gets the root element of the XML Tree for this document.
28.XDocument.Save (String) serialize this XDocument to a file, overwriting an existing file, if it exists.
29.XDocument.Save serialize this XDocument to a file, optionally disabling formatting.
30.XDocument.Save (TextWriter) serialize this XDocument to a TextWriter.
31.XDocument.Save (TextWriter, SaveOptions) serialize this XDocument to a TextWriter, optionally disabling formatting.
32.XObject.Document Property gets the XDocument for this XObject.
33.Extensions.XPathEvaluate
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.