選單
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

XML 教程

XML HOME XML Introduction XML How to use XML Tree XML Syntax XML Elements XML Attributes XML Namespaces XML Display XML HttpRequest XML Parser XML DOM XML XPath XML XSLT XML XQuery XML XLink XML Validator XML DTD XML Schema XML Server XML Examples XML Quiz XML Certificate

XML AJAX

AJAX Introduction AJAX XMLHttp AJAX Request AJAX Response AJAX XML File AJAX PHP AJAX ASP AJAX Database AJAX Applications AJAX Examples

XML DOM

DOM Introduction DOM Nodes DOM Accessing DOM Node Info DOM Node List DOM Traversing DOM Navigating DOM Get Values DOM Change Nodes DOM Remove Nodes DOM Replace Nodes DOM Create Nodes DOM Add Nodes DOM Clone Nodes DOM Examples

XPath 教程

XPath Introduction XPath Nodes XPath Syntax XPath Axes XPath Operators XPath Examples

XSLT 教程

XSLT Introduction XSL Languages XSLT Transform XSLT <template> XSLT <value-of> XSLT <for-each> XSLT <sort> XSLT <if> XSLT <choose> XSLT Apply XSLT on the Client XSLT on the Server XSLT Edit XML XSLT Examples

XQuery 教程

XQuery Introduction XQuery Example XQuery FLWOR XQuery HTML XQuery Terms XQuery Syntax XQuery Add XQuery Select XQuery Functions

XML DTD

DTD Introduction DTD Building Blocks DTD Elements DTD Attributes DTD Elements vs Attr DTD Entities DTD Examples

XSD Schema

XSD Introduction XSD How To XSD <schema> XSD Elements XSD Attributes XSD Restrictions XSD Complex Elements XSD Empty XSD Elements-only XSD Text-only XSD Mixed XSD Indicators XSD <any> XSD <anyAttribute> XSD Substitution XSD Example

XSD Data Types

XSD String XSD Date/Time XSD Numeric XSD Misc XSD Reference

Web Services

XML Services XML WSDL XML SOAP XML RDF XML RSS

參考手冊

DOM Node Types DOM Node DOM NodeList DOM NamedNodeMap DOM Document DOM Element DOM Attribute DOM Text DOM CDATA DOM Comment DOM XMLHttpRequest DOM Parser XSLT Elements XSLT/XPath Functions

XML DOM Node Types


DOM 將文件表示為一個節點物件的層次結構。


節點型別

下表列出了不同的 W3C 節點型別,以及它們可以擁有的子節點型別

節點型別 描述 子節點
文件 代表整個文件(DOM 樹的根節點) Element (最多一個)、ProcessingInstruction、Comment、DocumentType
DocumentFragment 代表一個“輕量級”的 Document 物件,可以包含文件的一部分 Element、ProcessingInstruction、Comment、Text、CDATASection、EntityReference
DocumentType 提供對文件定義的實體的介面
ProcessingInstruction 代表一個處理指令
EntityReference 代表一個實體引用 Element、ProcessingInstruction、Comment、Text、CDATASection、EntityReference
元素 代表一個元素 Element、Text、Comment、ProcessingInstruction、CDATASection、EntityReference
Attr 代表一個屬性 Text、EntityReference
文字 代表元素或屬性中的文字內容
CDATASection 代表文件中的 CDATA 部分(不會被解析器解析的文字)
註釋 代表一個註釋
實體 代表一個實體 Element、ProcessingInstruction、Comment、Text、CDATASection、EntityReference
Notation 代表 DTD 中宣告的一個符號


節點型別 - 返回值

下表列出了每個節點型別的 nodeName 和 nodeValue 屬性將返回什麼

節點型別 nodeName 返回 nodeValue 返回
文件 #document null
DocumentFragment #document fragment null
DocumentType doctype 名稱 null
EntityReference 實體引用名稱 null
元素 元素名稱 null
Attr 屬性名稱 屬性值
ProcessingInstruction target 節點的內容
註釋 #comment 註釋文字
文字 #text 節點的內容
CDATASection #cdata-section 節點的內容
實體 實體名稱 null
Notation 符號名稱 null

NodeTypes - 命名常量

NodeType 命名常量
1 ELEMENT_NODE
2 ATTRIBUTE_NODE
3 TEXT_NODE
4 CDATA_SECTION_NODE
5 ENTITY_REFERENCE_NODE
6 ENTITY_NODE
7 PROCESSING_INSTRUCTION_NODE
8 COMMENT_NODE
9 DOCUMENT_NODE
10 DOCUMENT_TYPE_NODE
11 DOCUMENT_FRAGMENT_NODE
12 NOTATION_NODE

×

聯絡銷售

如果您想將 W3Schools 服務用於教育機構、團隊或企業,請傳送電子郵件給我們
sales@w3schools.com

報告錯誤

如果您想報告錯誤,或想提出建議,請傳送電子郵件給我們
help@w3schools.com

W3Schools 經過最佳化,旨在方便學習和培訓。示例可能經過簡化,以提高閱讀和學習體驗。教程、參考資料和示例會不斷審查,以避免錯誤,但我們無法保證所有內容的完全正確性。使用 W3Schools 即表示您已閱讀並接受我們的使用條款Cookie 和隱私政策

版權所有 1999-2024 Refsnes Data。保留所有權利。W3Schools 由 W3.CSS 提供支援