XmlAttribute.BaseURI Proprietà

Definizione

Ottiene l'URI (Uniform Resource Identifier) di base del nodo.

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

Valore della proprietà

String

Percorso da cui è stato caricato il nodo o String.Empty se il nodo non dispone di un URI di base. I nodi dell'attributo hanno lo stesso URI di base dell'elemento proprietario. Se il nodo di un attributo non dispone di un elemento proprietario, BaseURI restituirà String.Empty.

Esempio

Nell'esempio seguente vengono visualizzate informazioni sul nodo dell'attributo, incluso l'URI di base.

#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

L'esempio usa il file , baseuri.xml, come input.


<!-- XML fragment -->
<book genre="novel">
  <title>Pride And Prejudice</title>
</book>

Commenti

Un documento XML in rete è costituito da blocchi di dati aggregati usando vari meccanismi di inclusione standard W3C (World Wide Web Consortium) e pertanto contiene nodi provenienti da posizioni diverse. Indica BaseURI da dove provengono questi nodi.

Per altre informazioni sul comportamento e sul BaseURI comportamento con altri tipi di nodo, vedere XmlNode.BaseURI.

Questa proprietà è un'estensione Microsoft di Document Object Model (DOM).

Si applica a

Vedi anche