Skip to main content
Sign in
Home
Samples
Languages
Extensions
Documentation
Community
Overview
Visual C++
Visual C#
Visual Basic
JavaScript
Visual F#
Get started for free
Visual Studio Developer Center
>
Languages
>
Visual Basic
>
101 Visual Basic LINQ Samples
>
LINQ To XML Samples
LINQ to XML Samples
Construction
Construct an XElement from string
Add XML declaration to a document
Computed element name
Document creation
Create an XmlSchema
Construct a PI
XML comment construction
Create a CData section
Create a sequence of nodes
DML
Add an element as the last child
Add an element as the first child
Add multiple elements as children
Add an attribute to an element
Add content to an existing element
Replace content of a container (element or document
Remove all content
Remove all attributes
Remove an attribute of an element
Update an attribute
Delete an element by name
Update a child element by name
Remove a list of elements
Remove a list of attributes
Add an un-parented element to an element
Add a parented element to a document
Grouping
Group orders by customer
Group customers by country and city
Language Integration
Find all orders for customers in a List
Find sum of items in a shopping cart
Consume a config file
Convert a Sequence of nodes to Array
Convert a Sequence of nodes to List
Create a dictionary of customers
Using anonymous types
Load
Load document from file
Load document from string
Load document from XmlReader
Element from XmlReader - 1
Element from XmlReader - 2
Miscellaneous
Get the outer XML of a node
Get the inner text of a node
Check if an element has attributes
Check if an element has element children
Check if an element is empty
Get the name of an element
Get the name of an attribute
Get the XML declaration
Find the type of the node
Verify phone numbers
Quick validation
Aggregate functions
Query
Query for child elements
Query for all child elements
Query for first child element - 1
Query for first child element - 2
Query for attributes
Cast an attribute to a number
Get the root element of a document
Filter query results using where
Select all descendants of an element
Select all descendants of a given type
Select all ancestors
Query for parent
Join over two sequences
Query content of a type
Query using XElement
Positional predicate
Union two sequences of nodes
Intersect two sequences of nodes
All nodes in sequence 1 except the nodes in sequence 2
Reverse the order of nodes in a sequence
Equality of sequences
Create a list of numbers
Repeat operator
Any operator
All operator
Count operartor
Aggregate operator
Distinct operator
Concat operator
Take operator
Skip operator
SelectMany operator
Container document
Fold operator
Sort
Sort customers by name
Sort orders by date
Descending order
Multiple sort keys
Transform
Create a table of customers
Create HTML tables of books
Write
Write an XElement to XmlWriter
Write the content of a Dim to XmlWriter
Save XDocument
XName
Create elements and attributes in a namespace
Query for elements in a namespace
Create a namespace prefix declaration
Local-name and namespace