XmlTextReader.BaseURI Proprietà

Definizione

Ottiene l'URI di base del nodo corrente.

public:
 virtual property System::String ^ BaseURI { System::String ^ get(); };
public override string BaseURI { get; }
public override string? BaseURI { get; }
member this.BaseURI : string
Public Overrides ReadOnly Property BaseURI As String

Valore della proprietà

URI di base del nodo corrente.

Esempio

Nell'esempio seguente viene visualizzato l'URI di base per ognuno dei nodi.

using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
    XmlTextReader reader = null;

    try
    {
        //Load the reader with the XML file.
        reader = new XmlTextReader("http://localhost/baseuri.xml");

        //Parse the file and display the base URI for each node.
        while (reader.Read())
        {
            Console.WriteLine("({0}) {1}", reader.NodeType, reader.BaseURI);
         }
     }

     finally
     {
       if (reader!=null)
         reader.Close();
     }
  }
} // End class
Option Explicit
Option Strict

Imports System.IO
Imports System.Xml

Public Class Sample
   
   Public Shared Sub Main()
      Dim reader As XmlTextReader = Nothing
      
      Try
         'Load the reader with the XML file.
         reader = New XmlTextReader("http://localhost/baseuri.xml")
         
         'Parse the file and display the base URI for each node.
         While reader.Read()
            Console.WriteLine("({0}) {1}", reader.NodeType, reader.BaseURI)
         End While
      
      Finally
         If Not (reader Is Nothing) Then
            reader.Close()
         End If
      End Try
   End Sub
End Class

Nell'esempio viene usato il file , baseuri.xml, come input.


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

Commenti

Note

È consigliabile creare XmlReader istanze usando il XmlReader.Create metodo per sfruttare le nuove funzionalità.

Un documento XML in rete è costituito da blocchi di dati aggregati usando vari meccanismi di inclusione standard W3C e pertanto contiene nodi provenienti da posizioni diverse. Le entità DTD sono un esempio di questo, ma questo non è limitato ai DTD. L'URI di base indica da dove provengono questi nodi. Se non è presente alcun URI di base per i nodi restituiti ( ad esempio, sono stati analizzati da una stringa in memoria), String.Empty viene restituito .

Si applica a

Vedi anche