XmlNode.CreateNavigator Metoda

Definicja

Tworzy obiekt do XPathNavigator nawigowania po tym obiekcie.

C#
public virtual System.Xml.XPath.XPathNavigator? CreateNavigator();
C#
public virtual System.Xml.XPath.XPathNavigator CreateNavigator();
C#
public System.Xml.XPath.XPathNavigator CreateNavigator();

Zwraca

Obiekt XPathNavigator używany do nawigowania po węźle. Element XPathNavigator jest umieszczony w węźle, z którego wywoływano metodę. Nie jest on umieszczony w katalogu głównym dokumentu.

Implementuje

Przykłady

Poniższy przykład ładuje i edytuje dokument XML przed wykonaniem przekształcenia XSLT.

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

Uwagi

Zapewnia XPathNavigator dostęp tylko do odczytu, losowy dostęp do danych. Ponieważ jest ona zoptymalizowana pod kątem przekształceń XSLT, zapewnia korzyści z wydajności, gdy są używane jako mechanizm wejściowy do XslTransform.Transform metody.

Ta metoda jest rozszerzeniem Microsoft do modelu obiektów dokumentów (DOM).

Dotyczy

Produkt Wersje
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Zobacz też