XML Tutorial

XML หน้าแรก บทนำ XML XML วิธีใช้งาน XML Tree ไวยากรณ์ XML องค์ประกอบ XML คุณสมบัติ XML XML เนมสเปซ จอแสดงผล XML XML HttpRequest XML Parser XML DOM XML XPath XML XSLT XML XQuery XML XLink เครื่องมือตรวจสอบ XML XML DTD XML Schema XML Server ตัวอย่าง XML แบบทดสอบ XML ใบรับรอง XML

XML AJAX

บทนำ AJAX AJAX XMLHttp คำขอ AJAX การตอบสนอง AJAX ไฟล์ AJAX XML AJAX PHP AJAX ASP ฐานข้อมูล AJAX แอปพลิเคชัน AJAX ตัวอย่าง AJAX

XML DOM

บทนำ DOM โหนด DOM การเข้าถึง DOM ข้อมูลโหนด DOM รายการโหนด DOM DOM Traversing การนำทาง 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 <sort> XSLT <if> XSLT <เลือก> ใช้ XSLT XSLT บนไคลเอนต์ XSLT บนเซิร์ฟเวอร์ XSLT แก้ไข XML ตัวอย่าง XSLT

กวดวิชาXQuery

บทนำ XQuery ตัวอย่าง XQuery XQuery FLWOR XQuery HTML ข้อกำหนด XQuery ไวยากรณ์ XQuery XQuery เพิ่ม XQuery Select ฟังก์ชัน XQuery

XML DTD

บทนำ DTD บล็อกตัวต่อ DTD องค์ประกอบ DTD คุณสมบัติ DTD องค์ประกอบ DTD เทียบกับ Attr หน่วยงาน DTD ตัวอย่าง DTD

ส คีมา XSD

บทนำ XSD XSD วิธีการ XSD <schema> องค์ประกอบ XSD แอตทริบิวต์ XSD ข้อจำกัด XSD

XSD Complex

องค์ประกอบ XSD XSD ว่างเปล่า องค์ประกอบ XSD เท่านั้น XSD Text เท่านั้น XSD ผสม ตัวชี้วัด XSD XSD <ใด ๆ> XSD <anyAttribute> การทดแทน XSD XSD ตัวอย่าง

ข้อมูลXSD

XSD สตริง วันที่ XSD XSD ตัวเลข XSD เบ็ดเตล็ด ข้อมูลอ้างอิง XSD

บริการเว็บ

XML Services XML WSDL XML SOAP XML RDF XML RSS

อ้างอิง

ประเภทโหนด DOM โหนด DOM DOM NodeList DOM NamedNodeMap เอกสาร DOM องค์ประกอบ DOM แอตทริบิวต์ DOM ข้อความ DOM DOM CDATA ความคิดเห็นของ DOM DOM XMLHttpRequest DOM Parser องค์ประกอบ XSLT ฟังก์ชัน XSLT/XPath

XML DOM - วัตถุองค์ประกอบ


วัตถุธาตุ

วัตถุองค์ประกอบแสดงถึงองค์ประกอบในเอกสาร XML องค์ประกอบอาจมีแอตทริบิวต์ องค์ประกอบอื่นๆ หรือข้อความ หากองค์ประกอบมีข้อความ ข้อความจะแสดงในโหนดข้อความ

สำคัญ! ข้อความจะถูกเก็บไว้ในโหนดข้อความเสมอ ข้อผิดพลาดทั่วไปในการประมวลผล DOM คือการนำทางไปยังโหนดองค์ประกอบและคาดว่าจะมีข้อความอยู่ อย่างไรก็ตาม แม้แต่โหนดองค์ประกอบที่ง่ายที่สุดก็มีโหนดข้อความอยู่ข้างใต้ ตัวอย่างเช่น ใน <ปี>2005</year> มีโหนดองค์ประกอบ (ปี) และโหนดข้อความใต้โหนดซึ่งมีข้อความ (2005)

เนื่องจากอ็อบเจ็กต์ Element ยังเป็นโหนดอีกด้วย จึงสืบทอดคุณสมบัติและวิธีการของอ็อบเจ็กต์โหนด

คุณสมบัติวัตถุองค์ประกอบ

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