Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

XML Document Literal (Visual Basic)

A literal representing an XDocument object.

<?xml version="1.0" [encoding="encoding"] [standalone="standalone"] ?>
[ piCommentList ]
rootElement
[ piCommentList ]

Term

Definition

encoding

Optional. Literal text declaring which encoding the document uses.

standalone

Optional. Literal text. Must be "yes" or "no".

piCommentList

Optional. List of XML processing instructions and XML comments. Takes the following format:

piComment [ piComment ... ]

Each piCommentcan be one of the following:

rootElement

Required. Root element of the document. The format is one of the following:

For more information, see Embedded Expressions in XML (Visual Basic).

An XML document literal is identified by the XML declaration at the start of the literal. Although each XML document literal must have exactly one root XML element, it can have any number of XML processing instructions and XML comments.

An XML document literal cannot appear in an XML element.

NoteNote

An XML literal can span multiple lines without using line continuation characters. This enables you to copy content from an XML document and paste it directly into a Visual Basic program.

The Visual Basic compiler converts the XML document literal into calls to the XDocument and XDeclaration constructors.

The following example creates an XML document that has an XML declaration, a processing instruction, a comment, and an element that contains another element.


Dim libraryRequest As XDocument = 
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <?xml-stylesheet type="text/xsl" href="show_book.xsl"?>
    <!-- Tests that the application works. -->
    <books>
        <book/>
    </books>
Console.WriteLine(libraryRequest)


Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.