XmlAttribute.BaseURI 属性
定义
获取节点的基统一资源标识符 (URI)。Gets the base Uniform Resource Identifier (URI) of the node.
public:
virtual property System::String ^ BaseURI { System::String ^ get(); };
public override string BaseURI { get; }
member this.BaseURI : string
Public Overrides ReadOnly Property BaseURI As String
属性值
从其加载节点的位置;如果节点没有基 URI,则为 String.Empty。The location from which the node was loaded or String.Empty if the node has no base URI. 特性节点与它们的所有者元素具有相同的基 URI。Attribute nodes have the same base URI as their owner element. 如果特性节点没有所有者元素,则 BaseURI 返回 String.Empty。If an attribute node does not have an owner element, BaseURI returns String.Empty.
示例
下面的示例显示了有关属性节点的信息,包括其基本 URI。The following example displays information on the attribute node, including its base URI.
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
//Create the XmlDocument.
XmlDocument^ doc = gcnew XmlDocument;
doc->Load( "http://localhost/baseuri.xml" );
//Display information on the attribute node. The value
//returned for BaseURI is 'http://localhost/baseuri.xml'.
XmlAttribute^ attr = doc->DocumentElement->Attributes[ 0 ];
Console::WriteLine( "Name of the attribute: {0}", attr->Name );
Console::WriteLine( "Base URI of the attribute: {0}", attr->BaseURI );
Console::WriteLine( "The value of the attribute: {0}", attr->InnerText );
}
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
//Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.Load("http://localhost/baseuri.xml");
//Display information on the attribute node. The value
//returned for BaseURI is 'http://localhost/baseuri.xml'.
XmlAttribute attr = doc.DocumentElement.Attributes[0];
Console.WriteLine("Name of the attribute: {0}", attr.Name);
Console.WriteLine("Base URI of the attribute: {0}", attr.BaseURI);
Console.WriteLine("The value of the attribute: {0}", attr.InnerText);
}
}
Option Explicit
Option Strict
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
'Create the XmlDocument.
Dim doc As New XmlDocument()
doc.Load("http://localhost/baseuri.xml")
'Display information on the attribute node. The value
'returned for BaseURI is 'http://localhost/baseuri.xml'.
Dim attr As XmlAttribute = doc.DocumentElement.Attributes(0)
Console.WriteLine("Name of the attribute: {0}", attr.Name)
Console.WriteLine("Base URI of the attribute: {0}", attr.BaseURI)
Console.WriteLine("The value of the attribute: {0}", attr.InnerText)
End Sub
End Class
该示例使用文件 baseuri.xml 作为输入。The sample uses the file, baseuri.xml, as input.
<!-- XML fragment -->
<book genre="novel">
<title>Pride And Prejudice</title>
</book>
注解
联网的 XML 文档包含使用各种万维网联合会 (W3C) 标准包含机制聚合的数据块,因此包含来自不同位置的节点。A networked XML document is comprised of chunks of data aggregated using various World Wide Web Consortium (W3C) standard inclusion mechanisms and therefore contains nodes that come from different places. BaseURI会告诉你这些节点的来源。The BaseURI tells you where these nodes came from.
有关 BaseURI 以及它如何与其他节点类型一起工作的其他信息,请参阅 XmlNode.BaseURI 。For additional information on BaseURI and how it behaves with other node types, see XmlNode.BaseURI.
此属性是文档对象模型 (DOM) 的 Microsoft 扩展。This property is a Microsoft extension to the Document Object Model (DOM).