Tutorial XML

RUMAH XML Pengantar XML XML Cara menggunakan Pohon XML Sintaks XML Elemen XML Atribut XML Ruang Nama XML Tampilan XML XML HttpRequest Pengurai XML XML DOM XML XPath XML XSLT XML XQuery XML XLink Validator XML XML DTD Skema XML Server XML Contoh XML Kuis XML Sertifikat XML

XML AJAX

Pengenalan AJAX AJAX XMLHttp Permintaan AJAX Tanggapan AJAX File XML AJAX AJAX PHP AJAX ASP Basis Data AJAX Aplikasi AJAX Contoh AJAX

XML DOM

Pengenalan DOM Node DOM Mengakses DOM Info Simpul DOM Daftar Simpul DOM Melintasi DOM Navigasi DOM DOM Dapatkan Nilai DOM Ubah Node DOM Hapus Node DOM Ganti Node DOM Buat Node DOM Tambahkan Node Node Klon DOM Contoh DOM

Tutorial XPath

Pengenalan XPath Node XPath Sintaks XPath Sumbu XPath Operator XPath Contoh XPath

Tutorial XSLT

Pengenalan XSLT Bahasa XSL Transformasi XSLT XSLT <templat> XSLT <nilai-dari> XSLT <untuk-setiap> XSLT <sort> XSLT <jika> XSLT <pilih> Terapkan XSLT XSLT di Klien XSLT di Server XSLT Sunting XML Contoh XSLT

Tutorial XQuery

Pengenalan XQuery Contoh XQuery XQuery FLWOR HTML XQuery Persyaratan XQuery Sintaks XQuery Tambahkan XQuery XQuery Pilih Fungsi XQuery

XML DTD

Pengenalan DTD Blok Bangunan DTD Elemen DTD Atribut DTD Elemen DTD vs Attr Entitas DTD Contoh DTD

Skema XSD

Pengenalan XSD XSD Bagaimana caranya? XSD <skema> Elemen XSD Atribut XSD Pembatasan XSD

Kompleks XSD

Elemen XSD XSD Kosong Elemen XSD Saja Hanya Teks XSD Campuran XSD Indikator XSD XSD <apa saja> XSD <anyAttribute> Pergantian XSD Contoh XSD

Data XSD

String XSD Tanggal XSD XSD Numerik XSD Lain-lain Referensi XSD

Layanan Web

Layanan XML XML WSDL XML SOAP XML RDF XML RSS

Referensi

Jenis Node DOM Simpul DOM Daftar Simpul DOM DOM BernamaNodeMap Dokumen DOM Elemen DOM Atribut DOM Teks DOM DOM CDATA Komentar DOM DOM XMLHttpRequest Pengurai DOM Elemen XSLT Fungsi XSLT/XPath

XML DOM - Objek Elemen


objek elemen

Objek Elemen mewakili elemen dalam dokumen XML. Elemen dapat berisi atribut, elemen lain, atau teks. Jika sebuah elemen berisi teks, teks tersebut direpresentasikan dalam sebuah text-node.

PENTING! Teks selalu disimpan dalam node teks. Kesalahan umum dalam pemrosesan DOM adalah menavigasi ke simpul elemen dan mengharapkannya berisi teks. Namun, bahkan simpul elemen paling sederhana pun memiliki simpul teks di bawahnya. Misalnya, pada <year>2005</year>, terdapat simpul elemen (tahun), dan simpul teks di bawahnya, yang berisi teks (2005).

Karena objek Element juga merupakan Node, ia mewarisi properti dan metode objek Node.

Properti Objek Elemen

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


Metode Objek Elemen

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