📄 element.html
字号:
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../org/w3c/dom/Attr.html">Attr</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/w3c/dom/Element.html#setAttributeNodeNS(org.w3c.dom.Attr)">setAttributeNodeNS</A></B>(<A HREF="../../../org/w3c/dom/Attr.html">Attr</A> newAttr)</CODE>
<BR>
Adds a new attribute.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/w3c/dom/Element.html#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)">setAttributeNS</A></B>(java.lang.String namespaceURI,
java.lang.String qualifiedName,
java.lang.String value)</CODE>
<BR>
Adds a new attribute.</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_org.w3c.dom.Node"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from interface org.w3c.dom.<A HREF="../../../org/w3c/dom/Node.html">Node</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../org/w3c/dom/Node.html#appendChild(org.w3c.dom.Node)">appendChild</A>, <A HREF="../../../org/w3c/dom/Node.html#cloneNode(boolean)">cloneNode</A>, <A HREF="../../../org/w3c/dom/Node.html#getAttributes()">getAttributes</A>, <A HREF="../../../org/w3c/dom/Node.html#getChildNodes()">getChildNodes</A>, <A HREF="../../../org/w3c/dom/Node.html#getFirstChild()">getFirstChild</A>, <A HREF="../../../org/w3c/dom/Node.html#getLastChild()">getLastChild</A>, <A HREF="../../../org/w3c/dom/Node.html#getLocalName()">getLocalName</A>, <A HREF="../../../org/w3c/dom/Node.html#getNamespaceURI()">getNamespaceURI</A>, <A HREF="../../../org/w3c/dom/Node.html#getNextSibling()">getNextSibling</A>, <A HREF="../../../org/w3c/dom/Node.html#getNodeName()">getNodeName</A>, <A HREF="../../../org/w3c/dom/Node.html#getNodeType()">getNodeType</A>, <A HREF="../../../org/w3c/dom/Node.html#getNodeValue()">getNodeValue</A>, <A HREF="../../../org/w3c/dom/Node.html#getOwnerDocument()">getOwnerDocument</A>, <A HREF="../../../org/w3c/dom/Node.html#getParentNode()">getParentNode</A>, <A HREF="../../../org/w3c/dom/Node.html#getPrefix()">getPrefix</A>, <A HREF="../../../org/w3c/dom/Node.html#getPreviousSibling()">getPreviousSibling</A>, <A HREF="../../../org/w3c/dom/Node.html#hasAttributes()">hasAttributes</A>, <A HREF="../../../org/w3c/dom/Node.html#hasChildNodes()">hasChildNodes</A>, <A HREF="../../../org/w3c/dom/Node.html#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)">insertBefore</A>, <A HREF="../../../org/w3c/dom/Node.html#isSupported(java.lang.String, java.lang.String)">isSupported</A>, <A HREF="../../../org/w3c/dom/Node.html#normalize()">normalize</A>, <A HREF="../../../org/w3c/dom/Node.html#removeChild(org.w3c.dom.Node)">removeChild</A>, <A HREF="../../../org/w3c/dom/Node.html#replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)">replaceChild</A>, <A HREF="../../../org/w3c/dom/Node.html#setNodeValue(java.lang.String)">setNodeValue</A>, <A HREF="../../../org/w3c/dom/Node.html#setPrefix(java.lang.String)">setPrefix</A></CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ FIELD DETAIL =========== -->
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="getTagName()"><!-- --></A><H3>
getTagName</H3>
<PRE>
public java.lang.String <B>getTagName</B>()</PRE>
<DL>
<DD>The name of the element. For example, in:
<pre> <elementExample
id="demo"> ... </elementExample> , </pre>
<code>tagName</code> has
the value <code>"elementExample"</code>. Note that this is
case-preserving in XML, as are all of the operations of the DOM. The
HTML DOM returns the <code>tagName</code> of an HTML element in the
canonical uppercase form, regardless of the case in the source HTML
document.<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getAttribute(java.lang.String)"><!-- --></A><H3>
getAttribute</H3>
<PRE>
public java.lang.String <B>getAttribute</B>(java.lang.String name)</PRE>
<DL>
<DD>Retrieves an attribute value by name.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - The name of the attribute to retrieve.<DT><B>Returns:</B><DD>The <code>Attr</code> value as a string, or the empty string
if that attribute does not have a specified or default value.</DL>
</DD>
</DL>
<HR>
<A NAME="setAttribute(java.lang.String, java.lang.String)"><!-- --></A><H3>
setAttribute</H3>
<PRE>
public void <B>setAttribute</B>(java.lang.String name,
java.lang.String value)
throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE>
<DL>
<DD>Adds a new attribute. If an attribute with that name is already present
in the element, its value is changed to be that of the value
parameter. This value is a simple string; it is not parsed as it is
being set. So any markup (such as syntax to be recognized as an
entity reference) is treated as literal text, and needs to be
appropriately escaped by the implementation when it is written out.
In order to assign an attribute value that contains entity
references, the user must create an <code>Attr</code> node plus any
<code>Text</code> and <code>EntityReference</code> nodes, build the
appropriate subtree, and use <code>setAttributeNode</code> to assign
it as the value of an attribute.
<br>To set an attribute with a qualified name and namespace URI, use
the <code>setAttributeNS</code> method.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - The name of the attribute to create or alter.<DD><CODE>value</CODE> - Value to set in string form.<DT><B>Throws:</B><DD><CODE><A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></CODE> - INVALID_CHARACTER_ERR: Raised if the specified name contains an
illegal character.
<br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</DL>
</DD>
</DL>
<HR>
<A NAME="removeAttribute(java.lang.String)"><!-- --></A><H3>
removeAttribute</H3>
<PRE>
public void <B>removeAttribute</B>(java.lang.String name)
throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE>
<DL>
<DD>Removes an attribute by name. If the removed attribute is known to have
a default value, an attribute immediately appears containing the
default value as well as the corresponding namespace URI, local name,
and prefix when applicable.
<br>To remove an attribute by local name and namespace URI, use the
<code>removeAttributeNS</code> method.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - The name of the attribute to remove.<DT><B>Throws:</B><DD><CODE><A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></CODE> - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</DL>
</DD>
</DL>
<HR>
<A NAME="getAttributeNode(java.lang.String)"><!-- --></A><H3>
getAttributeNode</H3>
<PRE>
public <A HREF="../../../org/w3c/dom/Attr.html">Attr</A> <B>getAttributeNode</B>(java.lang.String name)</PRE>
<DL>
<DD>Retrieves an attribute node by name.
<br>To retrieve an attribute node by qualified name and namespace URI,
use the <code>getAttributeNodeNS</code> method.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - The name (<code>nodeName</code>) of the attribute to
retrieve.<DT><B>Returns:</B><DD>The <code>Attr</code> node with the specified name (
<code>nodeName</code>) or <code>null</code> if there is no such
attribute.</DL>
</DD>
</DL>
<HR>
<A NAME="setAttributeNode(org.w3c.dom.Attr)"><!-- --></A><H3>
setAttributeNode</H3>
<PRE>
public <A HREF="../../../org/w3c/dom/Attr.html">Attr</A> <B>setAttributeNode</B>(<A HREF="../../../org/w3c/dom/Attr.html">Attr</A> newAttr)
throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE>
<DL>
<DD>Adds a new attribute node. If an attribute with that name (
<code>nodeName</code>) is already present in the element, it is
replaced by the new one.
<br>To add a new attribute node with a qualified name and namespace
URI, use the <code>setAttributeNodeNS</code> method.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>newAttr</CODE> - The <code>Attr</code> node to add to the attribute list.<DT><B>Returns:</B><DD>If the <code>newAttr</code> attribute replaces an existing
attribute, the replaced <code>Attr</code> node is returned,
otherwise <code>null</code> is returned.<DT><B>Throws:</B><DD><CODE><A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></CODE> - WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a
different document than the one that created the element.
<br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
<br>INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already an
attribute of another <code>Element</code> object. The DOM user must
explicitly clone <code>Attr</code> nodes to re-use them in other
elements.</DL>
</DD>
</DL>
<HR>
<A NAME="removeAttributeNode(org.w3c.dom.Attr)"><!-- --></A><H3>
removeAttributeNode</H3>
<PRE>
public <A HREF="../../../org/w3c/dom/Attr.html">Attr</A> <B>removeAttributeNode</B>(<A HREF="../../../org/w3c/dom/Attr.html">Attr</A> oldAttr)
throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE>
<DL>
<DD>Removes the specified attribute node. If the removed <code>Attr</code>
has a default value it is immediately replaced. The replacing
attribute has the same namespace URI and local name, as well as the
original prefix, when applicable.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>oldAttr</CODE> - The <code>Attr</code> node to remove from the attribute
list.<DT><B>Returns:</B><DD>The <code>Attr</code> node that was removed.<DT><B>Throws:</B><DD><CODE><A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></CODE> - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
<br>NOT_FOUND_ERR: Raised if <code>oldAttr</code> is not an attribute
of the element.</DL>
</DD>
</DL>
<HR>
<A NAME="getElementsByTagName(java.lang.String)"><!-- --></A><H3>
getElementsByTagName</H3>
<PRE>
public <A HREF="../../../org/w3c/dom/NodeList.html">NodeList</A> <B>getElementsByTagName</B>(java.lang.String name)</PRE>
<DL>
<DD>Returns a <code>NodeList</code> of all descendant <code>Elements</code>
with a given tag name, in the order in which they are encountered in
a preorder traversal of this <code>Element</code> tree.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - The name of the tag to match on. The special value "*"
matches all tags.<DT><B>Returns:</B><DD>A list of matching <code>Element</code> nodes.</DL>
</DD>
</DL>
<HR>
<A NAME="getAttributeNS(java.lang.String, java.lang.String)"><!-- --></A><H3>
getAttributeNS</H3>
<PRE>
public java.lang.String <B>getAttributeNS</B>(java.lang.String namespaceURI,
java.lang.String localName)</PRE>
<DL>
<DD>Retrieves an attribute value by local name and namespace URI.
<br>Documents which do not support the "XML" feature will permit only
the DOM Level 1 calls for creating/setting elements and attributes.
Hence, if you specify a non-null namespace URI, these DOMs will never
find a matching node.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>namespaceURI</CODE> - The namespace URI of the attribute to retrieve.<DD><CODE>localName</CODE> - The local name of the attribute to retrieve.<DT><B>Returns:</B><DD>The <code>Attr</code> value as a string, or the empty string
if that attribute does not have a specified or default value.<DT><B>Since: </B><DD>DOM Level 2</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setAttributeNS(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -