From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/xpathresult/index.html | 122 +++++++++++++++++++++ .../ja/web/api/xpathresult/snapshotitem/index.html | 85 ++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 files/ja/web/api/xpathresult/index.html create mode 100644 files/ja/web/api/xpathresult/snapshotitem/index.html (limited to 'files/ja/web/api/xpathresult') diff --git a/files/ja/web/api/xpathresult/index.html b/files/ja/web/api/xpathresult/index.html new file mode 100644 index 0000000000..166f1ae6e4 --- /dev/null +++ b/files/ja/web/api/xpathresult/index.html @@ -0,0 +1,122 @@ +--- +title: XPathResult +slug: Web/API/XPathResult +translation_of: Web/API/XPathResult +--- +

{{APIRef}}

+ +

Properties

+ +
+
{{domxref("XPathResult.booleanValue")}}
+
readonly boolean
+
+ +
+
{{domxref("XPathResult.invalidIteratorState")}}
+
readonly boolean
+
+ +
+
{{domxref("XPathResult.numberValue")}}
+
readonly float
+
+ +
+
{{domxref("XPathResult.resultType")}}
+
readonly integer (short)
+
+ +
+
{{domxref("XPathResult.singleNodeValue")}}
+
readonly Node
+
+ +
+
{{domxref("XPathResult.snapshotLength")}}
+
readonly Integer
+
+ +
+
{{domxref("XPathResult.stringValue")}}
+
readonly String
+
+ +

Methods

+ +
+
{{domxref("XPathResult.iterateNext()")}}
+
...
+
{{domxref("XPathResult.snapshotItem()")}}
+
...
+
+ +

Constants

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Result Type Defined ConstantValueDescription
ANY_TYPE0A result set containing whatever type naturally results from evaluation of the expression. Note that if the result is a node-set then UNORDERED_NODE_ITERATOR_TYPE is always the resulting type.
NUMBER_TYPE1A result containing a single number. This is useful for example, in an XPath expression using the count() function.
STRING_TYPE2A result containing a single string.
BOOLEAN_TYPE3A result containing a single boolean value. This is useful for example, in an XPath expression using the not() function.
UNORDERED_NODE_ITERATOR_TYPE4A result node-set containing all the nodes matching the expression. The nodes may not necessarily be in the same order that they appear in the document.
ORDERED_NODE_ITERATOR_TYPE5A result node-set containing all the nodes matching the expression. The nodes in the result set are in the same order that they appear in the document.
UNORDERED_NODE_SNAPSHOT_TYPE6A result node-set containing snapshots of all the nodes matching the expression. The nodes may not necessarily be in the same order that they appear in the document.
ORDERED_NODE_SNAPSHOT_TYPE7A result node-set containing snapshots of all the nodes matching the expression. The nodes in the result set are in the same order that they appear in the document.
ANY_UNORDERED_NODE_TYPE8A result node-set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression.
FIRST_ORDERED_NODE_TYPE9A result node-set containing the first node in the document that matches the expression.
+ +

See also

+ + diff --git a/files/ja/web/api/xpathresult/snapshotitem/index.html b/files/ja/web/api/xpathresult/snapshotitem/index.html new file mode 100644 index 0000000000..832a306960 --- /dev/null +++ b/files/ja/web/api/xpathresult/snapshotitem/index.html @@ -0,0 +1,85 @@ +--- +title: XPathResult.snapshotItem() +slug: Web/API/XPathResult/snapshotItem +tags: + - API + - DOM XPath API + - Method + - Reference + - XPath + - XPathResult + - メソッド +translation_of: Web/API/XPathResult/snapshotItem +--- +
{{APIRef("DOM XPath")}}
+ +

snapshotItem() は {{domxref("XPathResult")}} インターフェイスのメソッドで、アイテムのスナップショットのコレクション、または添字がノードの範囲を外れている場合は null を返します。イテレーターの返値とは異なり、スナップショットは無効になることはありませんが、変更したときに現在の文書に対応しない場合があります。

+ +

構文

+ +
var node = result.snapshotItem(i);
+
+ +

返値

+ +

XPathResult のノードセット内の指定された添字の {{domxref("Node")}} です。

+ +

例外

+ +

TYPE_ERR

+ +

{{domxref("XPathResult.resultType")}} が UNORDERED_NODE_SNAPSHOT_TYPE または ORDERED_NODE_SNAPSHOT_TYPE でない場合、 {{domxref("XPathException")}} による例外が TYPE_ERR 型で発生します。

+ +

+ +

以下の例は snapshotItem() メソッドの使用例を表しています。

+ +

HTML

+ +
<div>XPath example</div>
+<div>Tag names of the matched nodes: <output></output></div>
+
+ +

JavaScript

+ +
var xpath = "//div";
+var result = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+var node = null;
+var tagNames = [];
+for(var i = 0; i < result.snapshotLength; i++) {
+  var node = result.snapshotItem(i);
+  tagNames.push(node.localName);
+}
+document.querySelector("output").textContent = tagNames.join(", ");
+
+ +

結果

+ +

{{EmbedLiveSample('Example', 400, 70)}}

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName("DOM3 XPath", "xpath.html#XPathResult-snapshotItem", "XPathResult.snapshotItem()")}}{{Spec2("DOM3 XPath")}}初回定義
+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("api.WindowOrWorkerGlobalScope.clearTimeout")}}

+
-- cgit v1.2.3-54-g00ecf