Condividi tramite


XObject.BaseUri Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the base URI for this XObject.

Namespace:  System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

Syntax

'Declaration
Public ReadOnly Property BaseUri As String
public string BaseUri { get; }

Property Value

Type: System.String
A String that contains the base URI for this XObject.

Remarks

Using LINQ to XML, you can deserialize XML in a number of fashions. You can parse it from a string, load it from a file, or read it from a TextReader or an XmlReader. In all of these cases, LINQ to XML uses one or another of the concrete subclasses of XmlReader.

Sometimes the XmlReader has the base URI, and sometimes it does not. For instance, when loading from a file, the XmlReader knows the base URI, but when reading from an XmlReader that was created because of calling the Parse method, there is no possibility of the XmlReader reporting a base URI; the XML was in a string.

If, when parsing or loading the XML, you specify SetBaseUri, LINQ to XML will request the base URI for each node as the XmlReader returns the node. If the reader has the base URI, LINQ to XML will save the information with the LINQ to XML node. This property returns that information. If the underlying XmlReader does not have the base URI, then this property will return an empty string.

Setting SetBaseUri when loading an XML tree will result in slower parsing.

When setting the base URI for an XML tree, LINQ to XML puts an annotation on the root of the tree. This property is a computed property, and navigates up the tree to find the base URI.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.