📄 ch07_02.htm
字号:
<a name="INDEX-593" /><dt><i>removeNamedItem</i></dt><dd><p>Takes a node with the specified name out of the set and returns it. </p></dd><a name="INDEX-594" /><dt><i>item</i></dt><dd><p>Given an integer value <em class="replaceable">n</em>, returns areference to the <em class="replaceable">n</em>th node in the set. Notethat this method does not imply any order and is provided only forunique enumeration.</p></dd><a name="INDEX-595" /><dt><i>getNamedItemNS (DOM2 only)</i></dt><dd><p>Retrieves a node based on a namespace-qualified name (a namespaceprefix and local name).</p></dd><a name="INDEX-596" /><dt><i>removeNamedItemNS (DOM2 only)</i></dt><dd><p>Takes an item out of the list and returns it, based on itsnamespace-qualified name.</p></dd><a name="INDEX-597" /><dt><i>setNamedItemNS (DOM2 only)</i></dt><dd><p>Adds a node to the list using its namespace-qualified name. </p></dd></dl></div></div><a name="perlxml-CHP-7-SECT-2.7" /><div class="sect2"><h3 class="sect2">7.2.7. CharacterData</h3><p>This<a name="INDEX-598" /> class extends <tt class="literal">Node</tt> tofacilitate access to certain types of nodes that contain characterdata, such as <tt class="literal">Text</tt>,<tt class="literal">CDATASection</tt>, <tt class="literal">Comment</tt>, and<tt class="literal">ProcessingInstruction</tt>. Specific classes like<tt class="literal">Text</tt> inherit from this class.</p><a name="perlxml-CHP-7-SECT-2.7.1" /><div class="sect3"><h3 class="sect3">7.2.7.1. Properties</h3><dl><a name="INDEX-599" /><a name="INDEX-600" /><dt><i>data</i></dt><dd><p>The character data itself. </p></dd><a name="INDEX-601" /><dt><i>length</i></dt><dd><p>The number of characters in the data. </p></dd></dl></div><a name="perlxml-CHP-7-SECT-2.7.2" /><div class="sect3"><h3 class="sect3">7.2.7.2. Methods</h3><dl><a name="INDEX-602" /><dt><i>appendData</i></dt><dd><p>Appends a string of character data to the end of the<tt class="literal">data</tt> property.</p></dd><a name="INDEX-603" /><dt><i>substringData</i></dt><dd><p>Extracts and returns a segment of the <tt class="literal">data</tt>property from <em class="replaceable">offset</em> to<em class="replaceable">offset</em> + <em class="replaceable">count</em>.</p></dd><a name="INDEX-604" /><dt><i>insertData</i></dt><dd><p>Inserts a string inside the <tt class="literal">data</tt> property at thelocation given by <em class="replaceable">offset</em>.</p></dd><a name="INDEX-605" /><dt><i>deleteData</i></dt><dd><p>Sets the <tt class="literal">data</tt> property to an empty string. </p></dd><a name="INDEX-606" /><dt><i>replaceData</i></dt><dd><p>Changes the contents of <tt class="literal">data</tt> property with a newstring that you provide.</p></dd></dl></div></div><a name="perlxml-CHP-7-SECT-2.8" /><div class="sect2"><h3 class="sect2">7.2.8. Element</h3><p>This is the most<a name="INDEX-607" /> common type of node you will encounter. Anelement can contain other nodes and has attribute nodes.</p><a name="perlxml-CHP-7-SECT-2.8.1" /><div class="sect3"><h3 class="sect3">7.2.8.1. Properties</h3><dl><a name="INDEX-608" /><a name="INDEX-609" /><dt><i>tagname</i></dt><dd><p>The name of the element. </p></dd></dl></div><a name="perlxml-CHP-7-SECT-2.8.2" /><div class="sect3"><h3 class="sect3">7.2.8.2. Methods</h3><dl><a name="INDEX-610" /><a name="INDEX-611" /><a name="INDEX-612" /><dt><i>getAttribute, getAttributeNode</i></dt><dd><p>Returns the value of an attribute, or a reference to the attributenode, with a given name.</p></dd><a name="INDEX-613" /><a name="INDEX-614" /><dt><i>setAttribute, setAttributeNode</i></dt><dd><p>Adds a new attribute to the element's list orreplaces an existing attribute of the same name.</p></dd><a name="INDEX-615" /><a name="INDEX-616" /><dt><i>removeAttribute, removeAttributeNode</i></dt><dd><p>Returns the value of an attribute and removes it from theelement's list.</p></dd><a name="INDEX-617" /><dt><i>getElementsByTagName</i></dt><dd><p>Returns a <tt class="literal">NodeList</tt> of descendant elements whomatch a name.</p></dd><a name="INDEX-618" /><dt><i>normalize</i></dt><dd><p>Collapses adjacent text nodes. You should use this method wheneveryou add new text nodes to ensure that the structure of the documentremains the same, without erroneous extra children.</p></dd><a name="INDEX-619" /><dt><i>getAttributeNS (DOM2 only)</i></dt><dd><p>Retrieves an attribute value based on its qualified name (thenamespace prefix plus the local name).</p></dd><a name="INDEX-620" /><dt><i>getAttributeNodeNS (DOM2 only)</i></dt><dd><p>Gets an attribute's node by using its qualifiedname.</p></dd><a name="INDEX-621" /><dt><i>getElementsByTagNamesNS (DOM2 only)</i></dt><dd><p>Returns a <tt class="literal">NodeList</tt> of elements among thiselement's descendants that match a qualified name.</p></dd><a name="INDEX-622" /><dt><i>hasAttribute (DOM2 only)</i></dt><dd><p>Returns true if this element has an attribute with a given name. </p></dd><a name="INDEX-623" /><dt><i>hasAttributeNS (DOM2 only)</i></dt><dd><p>Returns true if this element has an attribute with a given qualifiedname.</p></dd><a name="INDEX-624" /><dt><i>removeAttributeNS (DOM2 only)</i></dt><dd><p>Removes and returns an attribute node from thiselement's list, based on its namespace-qualifiedname.</p></dd><a name="INDEX-625" /><dt><i>setAttributeNS (DOM2 only)</i></dt><dd><p>Adds a new attribute to the element's list, given anamespace-qualified name and a value.</p></dd><a name="INDEX-626" /><dt><i>setAttributeNodeNS (DOM2 only)</i></dt><dd><p>Adds a new attribute node to the element's list witha namespace-qualified name.</p></dd></dl></div></div><a name="perlxml-CHP-7-SECT-2.9" /><div class="sect2"><h3 class="sect2">7.2.9. Attr</h3><a name="perlxml-CHP-7-SECT-2.9.1" /><div class="sect3"><h3 class="sect3">7.2.9.1. Properties</h3><dl><a name="INDEX-627" /><a name="INDEX-628" /><a name="INDEX-629" /><dt><i>name</i></dt><dd><p>The attribute's name. </p></dd><a name="INDEX-630" /><dt><i>specified</i></dt><dd><p>If the program or the document explicitly set the attribute, thisproperty is true. If it was set in the DTD as a default and not resetanywhere else, then it will be false.</p></dd><a name="INDEX-631" /><dt><i>value</i></dt><dd><p>The attribute's value, represented as a text node. </p></dd><a name="INDEX-632" /><dt><i>ownerElement (DOM2 only)</i></dt><dd><p>The element to which this attribute belongs. </p></dd></dl></div></div><a name="perlxml-CHP-7-SECT-2.10" /><div class="sect2"><h3 class="sect2">7.2.10. Text</h3><a name="perlxml-CHP-7-SECT-2.10.1" /><div class="sect3"><h3 class="sect3">7.2.10.1. Methods</h3><dl><a name="INDEX-633" /><a name="INDEX-634" /><dt><i>splitText</i></dt><dd><p>Breaks the text node into two adjacent text nodes, each with part ofthe original text content. Content in the first node is from thebeginning of the original up to, but not including, a character whoseposition is given by <em class="replaceable">offset</em>. The secondnode has the rest of the original node's content.This method is useful for inserting a new element inside a span oftext.</p></dd></dl></div></div><a name="perlxml-CHP-7-SECT-2.11" /><div class="sect2"><h3 class="sect2">7.2.11. CDATASection</h3><p><tt class="literal">CDATA</tt><a name="INDEX-635" /> <tt class="literal">Section</tt> is like a textnode, but protects its contents from being parsed. It may containmarkup characters (<, &) that would be illegal in text nodes.Use generic <tt class="literal">Node</tt> methods to access data.</p></div><a name="perlxml-CHP-7-SECT-2.12" /><div class="sect2"><h3 class="sect2">7.2.12. ProcessingInstruction</h3><a name="perlxml-CHP-7-SECT-2.12.1" /><div class="sect3"><h3 class="sect3">7.2.12.1. Properties</h3><dl><a name="INDEX-636" /><a name="INDEX-637" /><a name="INDEX-638" /><dt><i>target</i></dt><dd><p>The target value for the node. </p></dd><a name="INDEX-639" /><dt><i>data</i></dt><dd><p>The data value for the node. </p></dd></dl></div></div><a name="perlxml-CHP-7-SECT-2.13" /><div class="sect2"><h3 class="sect2">7.2.13. Comment</h3><p>This is a <a name="INDEX-640" />class representing comment nodes. Use thegeneric <tt class="literal">Node</tt> methods to access the data.</p></div><a name="perlxml-CHP-7-SECT-2.14" /><div class="sect2"><h3 class="sect2">7.2.14. EntityReference</h3><p>This is a<a name="INDEX-641" /> reference to an entity defined by an<tt class="literal">Entity</tt><a name="INDEX-642" /> node. Sometimes the parser will beconfigured to resolve all entity references into their values foryou. If that option is disabled, the parser should create this node.No explicit methods force resolution, but some actions to the nodemay have that side effect.</p></div><a name="perlxml-CHP-7-SECT-2.15" /><div class="sect2"><h3 class="sect2">7.2.15. Entity</h3><p>This class provides access to an entity in the document, based oninformation in an entity declaration in the DTD.</p><a name="perlxml-CHP-7-SECT-2.15.1" /><div class="sect3"><h3 class="sect3">7.2.15.1. Properties</h3><dl><a name="INDEX-643" /><dt><i>publicId</i></dt><dd><p>A public identifier for the resource (if the entity is external tothe document).</p></dd><a name="INDEX-644" /><dt><i>systemId</i></dt><dd><p>A system identifier for the resource (if the entity is external tothe document).</p></dd><a name="INDEX-645" /><dt><i>notationName</i></dt><dd><p>If the entity is unparsed, its notation reference is listed here. </p></dd></dl></div></div><a name="perlxml-CHP-7-SECT-2.16" /><div class="sect2"><h3 class="sect2">7.2.16. Notation</h3><p><tt class="literal">Notation</tt><a name="INDEX-646" /> represents a notation declarationappearing in the DTD.</p><a name="perlxml-CHP-7-SECT-2.16.1" /><div class="sect3"><h3 class="sect3">7.2.16.1. Properties</h3><dl><a name="INDEX-647" /><a name="INDEX-648" /><dt><i>publicId</i></dt><dd><p>A public identifier for the notation. </p></dd><a name="INDEX-649" /><dt><i>systemId</i></dt><dd><p>A system identifier<a name="INDEX-650" /> for the notation<a name="INDEX-651" />.</p></dd></dl></div></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch07_01.htm"><img alt="Previous" border="0" src="../gifs/txtpreva.gif" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img alt="Home" border="0" src="../gifs/txthome.gif" /></a></td><td align="right" valign="top" width="228"><a href="ch07_03.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr><tr><td align="left" valign="top" width="228">7. DOM</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img alt="Book Index" border="0" src="../gifs/index.gif" /></a></td><td align="right" valign="top" width="228">7.3. XML::DOM</td></tr></table></div><hr width="684" align="left" /><img alt="Library Navigation Links" border="0" src="../gifs/navbar.gif" usemap="#library-map" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2002</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -