XmlNodeReader.BaseURI Propiedad

Definición

Obtiene el identificador URI base del nodo actual.

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

Valor de propiedad

String

Identificador URI base del nodo actual.

Ejemplos

En el ejemplo siguiente se analiza un archivo y se muestra el URI base de cada uno de los nodos.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlNodeReader^ reader = nullptr;
   try
   {
      
      //Create and load an XmlDocument.
      XmlDocument^ doc = gcnew XmlDocument;
      doc->Load( "http://localhost/uri.xml" );
      reader = gcnew XmlNodeReader( doc );
      
      //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();
   }

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

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

    try
    {
        //Create and load an XmlDocument.
        XmlDocument doc = new XmlDocument();
        doc.Load("http://localhost/uri.xml");

        reader = new XmlNodeReader(doc);

        //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 XmlNodeReader = Nothing
        
        Try
            'Create and load an XmlDocument.
            Dim doc As New XmlDocument()
            doc.Load("http://localhost/uri.xml")
            
            reader = New XmlNodeReader(doc)
            
            '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

En el ejemplo se usa el archivo , uri.xmlcomo entrada.


<!-- XML fragment -->
<!DOCTYPE book [<!ENTITY s SYSTEM "tmp/style.xml">]>
<book genre="novel">
  <title>Pride And Prejudice</title>
  <misc>&s;</misc>
</book>

El style.xml archivo contiene el texto <style>hardcover</style>XML .

Comentarios

Nota

En el .NET Framework 2.0, la práctica recomendada es crear XmlReader instancias mediante la XmlReaderSettings clase y el Create método . Esto le permite aprovechar al máximo todas las nuevas características introducidas en el .NET Framework. Para obtener más información, vea la sección Comentarios de la página de XmlReader referencia.

Un documento XML en red se compone de fragmentos de datos agregados mediante varios mecanismos de inclusión estándar W3C y, por tanto, contiene nodos procedentes de diferentes lugares. Las entidades DTD son un ejemplo de esto, pero esto no se limita a dtds. El URI base indica de dónde proceden estos nodos. Si no hay ningún URI base para los nodos que se devuelven (por ejemplo, se analizaron desde una cadena en memoria), se devuelve String.Empty.

Se aplica a