📄 dom_element.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 - Element 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 Element Object</h1>
<a href="dom_processinginstruction.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="dom_attribute.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>
<hr />
<p class="intro">The Element object represents an element in an XML document.</p>
<hr />
<h2>The Element object</h2>
<p>The Element object represents an element in an XML document. Elements may
contain attributes, other elements, or text. If an
element contains text, the text is represented in a text-node.</p>
<p><b>IMPORTANT!</b> Text is always stored in text nodes. A common error in DOM
processing is to navigate to an element node and expect it to contain the text.
However, even the simplest element node has a text node under it. For example,
in <year>2005</year>, there is an element node (year), and a text node under it,
which contains the text (2005).</p>
<p>Because the Element object is also a Node, it inherits the Node object's
properties and methods. </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>Element Object Properties</h3>
<table border="1" width="100%" class="ex" cellspacing="0" id="table8">
<tr>
<th width="25%" align="left" valign="top">Property</th>
<th width="55%" 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_element_attributes.asp">attributes</a></td>
<td valign="top">Returns a NamedNodeMap of attributes for the element</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_element_baseuri.asp">baseURI</a></td>
<td valign="top">Returns the absolute base URI of the element</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_element_childnodes.asp">childNodes</a></td>
<td valign="top">Returns a NodeList of child nodes for the element</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_element_firstchild.asp">firstChild</a></td>
<td valign="top">Returns the first child of the element</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_element_lastchild.asp">lastChild</a></td>
<td valign="top">Returns the last child of the element</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_element_localname.asp">localName</a></td>
<td valign="top">Returns the local part of the name of the element</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_element_namespaceuri.asp">namespaceURI</a></td>
<td valign="top">Returns the namespace URI of the element</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_element_nextsibling.asp">nextSibling</a></td>
<td valign="top">Returns the node immediately following the element</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_element_nodename.asp">nodeName</a></td>
<td valign="top">Returns the name of the 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_element_nodetype.asp">nodeType</a></td>
<td valign="top">Returns the type of the 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_element_ownerdocument.asp">ownerDocument</a></td>
<td valign="top">Returns the root element (document object) for an element</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_element_parentnode.asp">parentNode</a></td>
<td valign="top">Returns the parent node of the element</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_element_prefix.asp">prefix</a></td>
<td valign="top">Sets or returns the namespace prefix of the element</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_element_previoussibling.asp">previousSibling</a></td>
<td valign="top">Returns the node immediately before the element</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">schemaTypeInfo</td>
<td valign="top">Returns the type information associated with the element</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_element_tagname.asp">tagName</a></td>
<td valign="top">Returns the name of the element</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_element_textcontent.asp">textContent</a></td>
<td valign="top">Sets or returns the text content of the element and its
descendants</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_element_text.asp">text</a></td>
<td valign="top">Returns the text of the 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_element_xml.asp">xml</a></td>
<td valign="top">Returns the XML of the 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>
</table>
<h3>Element Object Methods</h3>
<table border="1" width="100%" class="ex" cellspacing="0" id="table9">
<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"><a href="met_element_appendchild.asp">appendChild()</a></td>
<td valign="top">Adds a new child node to the end of the list of children of
the 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_element_clonenode.asp">cloneNode()</a></td>
<td valign="top">Clones 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="met_element_comparedocumentposition.asp">compareDocumentPosition()</a></td>
<td valign="top">Compares the document position of two nodes</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="met_element_getattribute.asp">getAttribute()</a></td>
<td valign="top">Returns the value of an attribute</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_element_getattributens.asp">getAttributeNS()</a></td>
<td valign="top">Returns the value of an attribute (with a namespace)</td>
<td valign="top">No</td>
<td valign="top">1</td>
<td valign="top">9</td>
<td valign="top">Yes</td>
</tr>
<tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -