XMLチュートリアル

XMLホーム XMLの紹介 XML使用方法 XMLツリー XML構文 XML要素 XML属性 XML名前空間 XML表示 XML HttpRequest XMLパーサー XML DOM XML XPath XML XSLT XML XQuery XML XLink XMLバリデーター XML DTD XMLスキーマ XMLサーバー XMLの例 XMLクイズ XML証明書

XML AJAX

AJAXの紹介 AJAX XMLHttp AJAXリクエスト AJAX応答 AJAXXMLファイル AJAX PHP AJAX ASP AJAXデータベース AJAXアプリケーション AJAXの例

XML DOM

DOMの紹介 DOMノード DOMアクセス DOMノード情報 DOMノードリスト DOMトラバース DOMナビゲーション DOMは値を取得します DOM変更ノード DOM削除ノード DOM置換ノード DOM作成ノード DOM追加ノード DOMクローンノード DOMの例

XPathチュートリアル

XPathの概要 XPathノード XPath構文 XPath軸 XPath演算子 XPathの例

XSLTチュートリアル

XSLTの紹介 XSL言語 XSLT変換 XSLT <テンプレート> XSLT <値> XSLT <for-each> XSLT <ソート> XSLT <if> XSLT <選択> XSLT適用 クライアント上のXSLT サーバー上のXSLT XSLT Edit XML XSLTの例

XQueryチュートリアル

XQueryの紹介 XQueryの例 XQuery FLWOR XQuery HTML XQueryの用語 XQuery構文 XQuery追加 XQuery Select XQuery関数

XML DTD

DTDの紹介 DTDビルディングブロック DTD要素 DTD属性 DTD要素と属性 DTDエンティティ DTDの例

XSDスキーマ

XSDの概要 XSDハウツー XSD <スキーマ> XSD要素 XSD属性 XSDの制限

XSDコンプレックス

XSD要素 XSDが空です XSD要素のみ XSDテキストのみ XSD混合 XSDインジケーター XSD <任意> XSD <anyAttribute> XSD置換 XSDの例

XSDデータ

XSD文字列 XSD日付 XSD数値 XSDその他 XSDリファレンス

Webサービス

XMLサービス XML WSDL XML SOAP XML RDF XML RSS

参考文献

DOMノードタイプ DOMノード DOM NodeList DOM NamedNodeMap DOMドキュメント DOM要素 DOM属性 DOMテキスト DOM CDATA DOMコメント DOM XMLHttpRequest DOMパーサー XSLT要素 XSLT / XPath関数

XMLDOM-要素オブジェクト


Elementオブジェクト

Elementオブジェクトは、XMLドキュメント内の要素を表します。要素には、属性、他の要素、またはテキストが含まれる場合があります。要素にテキストが含まれている場合、テキストはテキストノードで表されます。

重要!テキストは常にテキストノードに保存されます。DOM処理でよくあるエラーは、要素ノードに移動して、テキストが含まれていることを期待することです。ただし、最も単純な要素ノードでさえ、その下にテキストノードがあります。たとえば、<year> 2005 </ year>には、要素ノード(year)と、その下にテキスト(2005)を含むテキストノードがあります。

ElementオブジェクトもNodeであるため、Nodeオブジェクトのプロパティとメソッドを継承します。

要素オブジェクトのプロパティ

Property Description
attributes Returns a NamedNodeMap of attributes for the element
baseURI Returns the absolute base URI of the element
childNodes Returns a NodeList of child nodes for the element
firstChild Returns the first child of the element
lastChild Returns the last child of the element
localName Returns the local part of the name of the element
namespaceURI Returns the namespace URI of the element
nextSibling Returns the node immediately following the element
nodeName Returns the name of the node, depending on its type
nodeType Returns the type of the node
ownerDocument Returns the root element (document object) for an element
parentNode Returns the parent node of the element
prefix Sets or returns the namespace prefix of the element
previousSibling Returns the node immediately before the element
schemaTypeInfo Returns the type information associated with the element
tagName Returns the name of the element
textContent Sets or returns the text content of the element and its descendants


要素オブジェクトメソッド

Method Description
appendChild() Adds a new child node to the end of the list of children of the node
cloneNode() Clones a node
compareDocumentPosition() Compares the document position of two nodes
getAttribute() Returns the value of an attribute
getAttributeNS() Returns the value of an attribute (with a namespace)
getAttributeNode() Returns an attribute node as an Attribute object
getAttributeNodeNS() Returns an attribute node (with a namespace) as an Attribute object
getElementsByTagName() Returns a NodeList of matching element nodes, and their children
getElementsByTagNameNS() Returns a NodeList of matching element nodes (with a namespace), and their children
getFeature(feature,version) Returns a DOM object which implements the specialized APIs of the specified feature and version
getUserData(key) Returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key
hasAttribute() Returns whether an element has any attributes matching a specified name
hasAttributeNS() Returns whether an element has any attributes matching a specified name and namespace
hasAttributes() Returns whether the element has any attributes
hasChildNodes() Returns whether the element has any child nodes
insertBefore() Inserts a new child node before an existing child node
isDefaultNamespace(URI) Returns whether the specified namespaceURI is the default
isEqualNode() Checks if two nodes are equal
lookupNamespaceURI() Returns the namespace URI matching a specified prefix
lookupPrefix() Returns the prefix matching a specified namespace URI
normalize() Puts all text nodes underneath this element (including attributes) into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes
removeAttribute() Removes a specified attribute
removeAttributeNS() Removes a specified attribute (with a namespace)
removeAttributeNode() Removes a specified attribute node
removeChild() Removes a child node
replaceChild() Replaces a child node
setUserData(key,data,handler) Associates an object to a key on the element
setAttribute() Adds a new attribute
setAttributeNS() Adds a new attribute (with a namespace)
setAttributeNode() Adds a new attribute node
setAttributeNodeNS(attrnode) Adds a new attribute node (with a namespace)
setIdAttribute(name,isId) If the isId property of the Attribute object is true, this method declares the specified attribute to be a user-determined ID attribute
setIdAttributeNS(uri,name,isId) If the isId property of the Attribute object is true, this method declares the specified attribute (with a namespace) to be a user-determined ID attribute
setIdAttributeNode(idAttr,isId) If the isId property of the Attribute object is true, this method declares the specified attribute to be a user-determined ID attribute