XmlNode.CreateNavigator XmlNode.CreateNavigator XmlNode.CreateNavigator XmlNode.CreateNavigator Method

Definizione

Crea un oggetto XPathNavigator per l'esplorazione dell'oggetto corrente.Creates an XPathNavigator for navigating this object.

public:
 virtual System::Xml::XPath::XPathNavigator ^ CreateNavigator();
public System.Xml.XPath.XPathNavigator CreateNavigator ();
abstract member CreateNavigator : unit -> System.Xml.XPath.XPathNavigator
override this.CreateNavigator : unit -> System.Xml.XPath.XPathNavigator
Public Function CreateNavigator () As XPathNavigator

Restituisce

Oggetto XPathNavigator usato per esplorare il nodo.An XPathNavigator object used to navigate the node. L'oggetto XPathNavigator è posizionato sul nodo dal quale è stato chiamato il metodo,The XPathNavigator is positioned on the node from which the method was called. non nella radice del documento.It is not positioned on the root of the document.

Implementazioni

Esempi

Nell'esempio seguente viene caricato e modificato un documento XML prima di eseguire una trasformazione XSLT.The following example loads and edits an XML document before performing an XSLT transform.

XmlDocument^ doc = gcnew XmlDocument;
doc->Load( "books.xml" );

// Modify the XML file.
XmlElement^ root = doc->DocumentElement;
root->FirstChild->LastChild->InnerText = "12.95";

// Create an XPathNavigator to use for the transform.
XPathNavigator^ nav = root->CreateNavigator();

// Transform the file.
XslTransform^ xslt = gcnew XslTransform;
xslt->Load( "output.xsl" );
XmlTextWriter^ writer = gcnew XmlTextWriter( "books.html", nullptr );
xslt->Transform( nav, nullptr, writer, nullptr);
XmlDocument doc = new XmlDocument();
doc.Load("books.xml");

// Modify the XML file.
XmlElement root = doc.DocumentElement;
root.FirstChild.LastChild.InnerText = "12.95";

// Create an XPathNavigator to use for the transform.
XPathNavigator nav = root.CreateNavigator();

// Transform the file.
XslTransform xslt = new XslTransform();
xslt.Load("output.xsl");
XmlTextWriter writer = new XmlTextWriter("books.html", null);
xslt.Transform(nav, null, writer, null);
Dim doc as XmlDocument = new XmlDocument()
doc.Load("books.xml")

' Modify the XML file.
Dim root as XmlElement = doc.DocumentElement
root.FirstChild.LastChild.InnerText = "12.95"

' Create an XPathNavigator to use for the transform.
Dim nav as XPathNavigator = root.CreateNavigator()

' Transform the file.
Dim xslt as XslTransform = new XslTransform()
xslt.Load("output.xsl")
Dim writer as XmlTextWriter = new XmlTextWriter("books.html", nothing)
xslt.Transform(nav,nothing, writer, nothing)

Commenti

Il XPathNavigator fornisce accesso casuale di sola lettura ai dati.The XPathNavigator provides read-only, random access to data. Poiché è ottimizzato per le trasformazioni XSLT, offre vantaggi in merito alle prestazioni quando viene usato come meccanismo di input per il metodo XslTransform.Transform.Because it is optimized for XSLT transformations, it provides performance benefits when used as an input mechanism to the XslTransform.Transform method.

Questo metodo è un'estensione Microsoft per il Document Object Model (DOM).This method is a Microsoft extension to the Document Object Model (DOM).

Si applica a

Vedi anche