Proprietà XmlTextReader.BaseURI (System.Xml)

Cambia visualizzazione:
ScriptFree
Riferimento a .NET Framework
Proprietà XmlTextReader.BaseURI

Ottiene l'URI di base del nodo corrente.

Spazio dei nomi: System.Xml
Assembly: System.Xml (in system.xml.dll)

Sintassi

Visual Basic - (Dichiarazione)
Public Overrides ReadOnly Property BaseURI As String
Visual Basic (Utilizzo)
Dim instance As XmlTextReader
Dim value As String

value = instance.BaseURI

C#
public override string BaseURI { get; }
C++
public:
virtual property String^ BaseURI {
	String^ get () override;
}
J#
/** @property */
public String get_BaseURI ()

JScript
public override function get BaseURI () : String

Valore proprietà

URI di base del nodo corrente.
Note

NotaNota

Nella versione Microsoft .NET Framework versione 2.0 è consigliabile creare istanze di XmlReader utilizzando il metodo System.Xml.XmlReader.Create. In questo modo è possibile sfruttare completamente le nuove funzionalità introdotte in questa versione. Per ulteriori informazioni, vedere Creazione di lettori XML.

Un documento XML in rete è costituito da blocchi di dati aggregati tramite vari meccanismi di inclusione W3C standard, pertanto contiene nodi provenienti da posizioni diverse. Le entità DTD rappresentano solo un esempio di tale documento. L'URI di base indica la provenienza dei nodi. Se non è presente un URI di base per i nodi restituiti, ad esempio se questi sono stati analizzati da una stringa in memoria, verrà restituito il valore String.Empty.

Esempio

Nell'esempio seguente viene visualizzato l'URI di base per ciascun nodo.

Visual Basic
Option Explicit
Option Strict

Imports System
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 'Main ' End class
End Class 'Sample 

C#
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

C++
#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlTextReader^ reader = nullptr;
   try
   {
      
      //Load the reader with the XML file.
      reader = gcnew 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 != nullptr )
            reader->Close();
   }

}


J#
import System.*;
import System.IO.*;
import System.Xml.*;

public class Sample
{  
    public static void main(String[] args)
    {
        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.get_NodeType(),
                reader.get_BaseURI());
            }
        }
        finally {
            if ( reader != null ) {
                reader.Close();
            }
        }
    } //main
} // End class Sample

Nell'esempio viene utilizzato il file baseuri.xml come input.


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

Piattaforme

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile per Pocket PC, Windows Mobile per Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema.

Informazioni sulla versione

.NET Framework

Supportato in: 2.0 1.1 1.0

.NET Compact Framework

Supportato in: 2.0 1.0
Vedere anche