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

XObject.BaseUri Property

Gets the base URI for this XObject.

Namespace:  System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)
public string BaseUri { get; }

Property Value

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

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.

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

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

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.