XmlEntityReference.BaseURI 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得目前節點的基本統一資源識別碼(URI)。
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。
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/uri.xml");
//Display information on the entity reference node.
XmlEntityReference entref = (XmlEntityReference) doc.DocumentElement.LastChild.FirstChild;
Console.WriteLine("Name of the entity reference: {0}", entref.Name);
Console.WriteLine("Base URI of the entity reference: {0}", entref.BaseURI);
Console.WriteLine("The entity replacement text: {0}", entref.InnerText);
}
}
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
'Create the XmlDocument.
Dim doc as XmlDocument = new XmlDocument()
doc.Load("http://localhost/uri.xml")
'Display information on the entity reference node.
Dim entref as XmlEntityReference = CType(doc.DocumentElement.LastChild.FirstChild, XmlEntityReference)
Console.WriteLine("Name of the entity reference: {0}", entref.Name)
Console.WriteLine("Base URI of the entity reference: {0}", entref.BaseURI)
Console.WriteLine("The entity replacement text: {0}", entref.InnerText)
end sub
end class
範例使用檔案 uri.xml, 作為輸入。
<!-- XML fragment -->
<!DOCTYPE book [<!ENTITY s SYSTEM "tmp/style.xml">]>
<book genre="novel">
<title>Pride and Prejudice</title>
<misc>&s;</misc>
</book>
該 style.xml 檔案包含 XML 字串 <style>hardcover</style>。
備註
網路化的 XML 文件由各種萬維網聯盟(W3C)標準納入機制聚合的資料塊組成,因此包含來自不同來源的節點。 它 BaseURI 告訴你這些節點的來源。 如果回傳的節點沒有基礎 URI(可能是從記憶體內字串解析出來的 Empty ),則會回傳。
BaseURI 會遍歷節點樹尋找實體參考邊界,因此若實體展開,該資訊不會被保留,且此屬性在所有情況下都會回傳 XmlDocument 的位置。
關於它和其他節點類型互動的更多資訊 BaseURI ,請參見 XmlNode.BaseURI。
此屬性是 Microsoft 對文件物件模型(DOM)的擴充。