📄 dom_document.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML DOM - Document object</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>XML DOM - The Document Object</h1>
<a href="dom_namednodemap.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="dom_documentimplementation.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>
<hr />
<p class="intro">The Document object represents the entire XML document.</p>
<hr />
<h2>The Document object</h2>
<p>The Document object is the root of a document tree, and gives us the primary
access to the document's data.</p>
<p>Since element nodes, text nodes, comments, processing instructions, etc.
cannot exist outside the document, the Document object also contains methods to
create these objects. The Node objects have a ownerDocument property which
associates them with the Document where they were created.</p>
<p>
<b>IE:</b> Internet Explorer, <b>F:</b> Firefox, <b>O:</b> Opera, <b>W3C:</b>
World Wide Web Consortium (Internet Standard)</p>
<h3>Document Object Properties</h3>
<table border="1" width="100%" class="ex" cellspacing="0">
<tr>
<th width="32%" align="left" valign="top">Property</th>
<th width="48%" align="left" valign="top">Description</th>
<th width="5%" align="left" valign="top">IE</th>
<th width="4%" align="left" valign="top">F</th>
<th width="4%" align="left" valign="top">O</th>
<th width="7%" align="left" valign="top">W3C</th>
</tr>
<tr>
<td valign="top"><a href="prop_document_async.asp">async</a></td>
<td valign="top">Specifies whether downloading of an XML file should be
handled asynchronously or not</td>
<td valign="top">5</td>
<td valign="top">1.5</td>
<td valign="top">9</td>
<td valign="top">No</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_childnodes.asp">childNodes</a></td>
<td valign="top">Returns a NodeList of child nodes for the document</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_doctype.asp">doctype</a></td>
<td valign="top">Returns the Document Type Declaration associated with the
document</td>
<td valign="top">6</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_documentelement.asp">documentElement</a></td>
<td valign="top">Returns the root node of the document</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_documenturi.asp">documentURI</a></td>
<td valign="top">Sets or returns the location of the document</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top">domConfig</td>
<td valign="top">Returns the configuration used when
normalizeDocument() is invoked</td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_firstchild.asp">firstChild</a></td>
<td valign="top">Returns the first child node of the document</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_implementation.asp">implementation</a></td>
<td valign="top">Returns the DOMImplementation object that handles this
document</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_inputencoding.asp">inputEncoding</a></td>
<td valign="top">Returns the encoding used for the document (when parsing)</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_lastchild.asp">lastChild</a></td>
<td valign="top">Returns the last child node of the document</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_nodename.asp">nodeName</a></td>
<td valign="top">Returns the name of a node (depending on its type)</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_nodetype.asp">nodeType</a></td>
<td valign="top">Returns the node type of a node</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_nodevalue.asp">nodeValue</a></td>
<td valign="top">Sets or returns the value of a node (depending on its
type)</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_stricterrorchecking.asp">strictErrorChecking</a></td>
<td valign="top">Sets or returns whether error-checking is enforced or not</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_text.asp">text</a></td>
<td valign="top">Returns the text of a node and its descendants.
IE-only property</td>
<td valign="top">5</td>
<td valign="top">No</td>
<td valign="top">No</td>
<td valign="top">No</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_xml.asp">xml</a></td>
<td valign="top">Returns the XML of a node and its descendants. IE-only
property</td>
<td valign="top">5</td>
<td valign="top">No</td>
<td valign="top">No</td>
<td valign="top">No</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_xmlencoding.asp">xmlEncoding</a></td>
<td valign="top">Returns the XML encoding of the document</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_xmlstandalone.asp">xmlStandalone</a></td>
<td valign="top">Sets or returns whether the document is standalone</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="prop_document_xmlversion.asp">xmlVersion</a></td>
<td valign="top">Sets or returns the XML version of the document</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
</table>
<h3>Document Object Methods</h3>
<table border="1" width="100%" class="ex" cellspacing="0">
<tr>
<th width="40%" align="left" valign="top">Method</th>
<th width="40%" align="left" valign="top">Description</th>
<th width="5%" align="left" valign="top">IE</th>
<th width="4%" align="left" valign="top">F</th>
<th width="4%" align="left" valign="top">O</th>
<th width="7%" align="left" valign="top">W3C</th>
</tr>
<tr>
<td valign="top">adoptNode(sourcenode)</td>
<td valign="top">Adopts a node from another document to this document, and
returns the adopted node</td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top">createAttribute(name)</td>
<td valign="top">Creates an attribute node with the specified name, and
returns the new Attr object</td>
<td valign="top">6</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top">createAttributeNS(uri,name)</td>
<td valign="top">Creates an attribute node with the specified name and
namespace, and returns the new Attr object</td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="met_document_createcdatasection.asp">createCDATASection()</a></td>
<td valign="top">Creates a CDATA section node</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="met_document_createcomment.asp">createComment()</a></td>
<td valign="top">Creates a comment node</td>
<td valign="top">6</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top">createDocumentFragment()</td>
<td valign="top">Creates an empty DocumentFragment object, and returns it</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="met_document_createelement.asp">createElement()</a></td>
<td valign="top">Creates an element node</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="met_document_createelementns.asp">createElementNS()</a></td>
<td valign="top">Creates an element node with a specified namespace</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top">createEntityReference(name)</td>
<td valign="top">Creates an EntityReference object, and returns it</td>
<td valign="top">5</td>
<td valign="top"> </td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top">createProcessingInstruction(target,data)</td>
<td valign="top">Creates a ProcessingInstruction object, and returns it</td>
<td valign="top">5</td>
<td valign="top"> </td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="met_document_createtextnode.asp">createTextNode()</a></td>
<td valign="top">Creates a text node</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top">getElementById(id)</td>
<td valign="top">Returns the element that has an ID attribute with the given
value. If no such element exists, it returns null</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="met_document_getelementsbytagname.asp">getElementsByTagName()</a></td>
<td valign="top">Returns a NodeList of all elements with a specified name</td>
<td valign="top">5</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="met_document_getelementsbytagnamens.asp">getElementsByTagNameNS()</a></td>
<td valign="top">Returns a NodeList of all elements with a specified name
and namespace</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top">importNode(nodetoimport,deep)</td>
<td valign="top">Imports a node from another document to this document. This
method creates a new copy of the source node. If the deep parameter is set
to true, it imports all children of the specified node. If set to false, it
imports only the node itself. This method returns the imported node</td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top">normalizeDocument()</td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><a href="met_document_renamenode.asp">renameNode()</a></td>
<td valign="top">Renames an element or attribute node</td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
</table>
<br />
<hr />
<a href="dom_namednodemap.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="dom_documentimplementation.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -