次の方法で共有


XmlNode.CreateNavigator メソッド

このオブジェクト内を移動するための XPathNavigator を作成します。

Public Overridable Function CreateNavigator() As XPathNavigator _   Implements IXPathNavigable.CreateNavigator
[C#]
public virtual XPathNavigator CreateNavigator();
[C++]
public: virtual XPathNavigator* CreateNavigator();
[JScript]
public function CreateNavigator() : XPathNavigator;

戻り値

XPathNavigator オブジェクト。 XPathNavigator は、メソッドの呼び出し元のノードに配置されます。ドキュメントのルートには配置されません。

実装

IXPathNavigable.CreateNavigator

解説

XPathNavigator は、データへの読み取り専用のランダム アクセスを提供します。XSLT 変換用に最適化されているため、 XslTransform.Transform メソッドへの入力機構として使用すると、パフォーマンスが向上します。

このメソッドは、ドキュメント オブジェクト モデル (DOM: Document Object Model) に対する Microsoft 拡張機能です。

使用例

XSLT 変換を実行する前に XML ドキュメントを読み込み、編集する例を次に示します。

 
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)

[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);

[C++] 
XmlDocument* doc = new XmlDocument();
doc -> Load(S"books.xml");

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

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

// Transform the file.
XslTransform* xslt = new XslTransform();
xslt -> Load(S"output.xsl");
XmlTextWriter* writer = new XmlTextWriter(S"books.html", 0);
xslt -> Transform(nav, 0, writer, 0);

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

XmlNode クラス | XmlNode メンバ | System.Xml 名前空間 | XslTransform