After you type a period (.) to delimit an instance of an XElement or XDocument object (or an instance of IEnumerable(Of XElement) or IEnumerable(Of XDocument)), Visual Basic IntelliSense displays a list of possible object members. The initial list includes three options that represent XML axis properties, as described in the following list.
- < >
Select this option to show a list of possible child elements. For more information, see XML Element Literal and the Elements method.
- @
Select this option to show a list of possible attributes. For more information, see XML Axis Properties.This option is available only for objects of type XElement.
- …< >
Select this option to show a list of possible descendant elements. For more information, see How to: Access XML Descendant Elements (Visual Basic) and the Elements method.
Select or begin typing any of the XML options from the list. The member list will then display potential members from the XML schema that are specific to the selected option. If you have XML namespaces imported that are associated with a specific XML namespace prefix, a list of potential XML namespace prefixes is included in the member list.
For example, consider the following XSD schema.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://SamplePurchaseOrder"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="PurchaseOrders">
<xs:complexType>
<xs:sequence>
<xs:element name="PurchaseOrder">
<xs:complexType>
<xs:sequence>
<xs:element name="Address" />
<xs:element name="Items" />
<xs:element name="Comment" />
</xs:sequence>
<xs:attribute name="PurchaseOrderNumber" type="xs:unsignedShort" use="required" />
<xs:attribute name="OrderDate" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Valid XML for the XSD schema would resemble the following.
<?xml version="1.0"?>
<PurchaseOrders xmlns="http://SamplePurchaseOrder">
<PurchaseOrder PurchaseOrderNumber="12345" OrderDate="2000-1-1">
<Address />
<Items />
<Comment />
</PurchaseOrder>
</PurchaseOrders>
If you include this XSD schema file in a project and import the target namespace from the XSD schema into your code file or project, Visual Basic IntelliSense displays members from the schema as you type your Visual Basic code. If the target namespace for the XSD schema is imported as the default namespace and you type the following, IntelliSense displays a list of possible child elements for the PurchaseOrder XML element.
Dim po = <PurchaseOrder />
po.<
The list consists of the Address, Comment, and Items elements.
Certainty Levels for IntelliSense List Items
Determining the XSD type to use for IntelliSense is not exact. As a result, XML IntelliSense will often show an expanded list of possible members. To aid you in selecting an item from the IntelliSense member list, items are displayed with an indication of the level of certainty that XML IntelliSense has for a particular member.
Sometimes XML IntelliSense can identify a specific type from the XSD schema. In these cases, it will display possible child elements, attributes, or descendant elements for that XSD type with a high degree of certainty. These items are identified with a check mark.
However, sometimes XML IntelliSense is not able to identify a specific type from the XSD schema. In these cases, it will display an expanded list of possible child elements, attributes, or descendant elements from the XSD schema for the project with a low degree of certainty. These items are identified with a question mark.