var attrNode = xml.documentElement.getAttributeNode("myAttr")




Download 2,96 Mb.
Pdf ko'rish
bet119/131
Sana14.05.2024
Hajmi2,96 Mb.
#232039
1   ...   115   116   117   118   119   120   121   122   ...   131
Bog'liq
Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers







- 133 -



This example takes the attribute myAttr=“”hello” off rootElement and puts it on myElem. If 
the tree was to be persisted (saved to disk), then the XML document would appear as 
follows:



In Internet Explorer 5, if the line xml.documentElement.removeAttributeNode(attrNode) 
was removed from the script, an error would be issued saying that the node must first be 
removed from before inserting into another element.
getElementsByTagName(name)
Parameters

name
is a string value.
Return value
: NodeList
Exceptions
thrown:
None
Description
: Returns a list of Element nodes that have a property tagName (or 
nodeValue) that matches the parameter name name. This method searches the whole 
subtree of the Element that it was called on. If name equals “*”, then all the Element 
nodes are returned.
Comments
: This method is performs the same operation as the get-
ElementsByTagName(name) method that is found on the Document node. The 
Document node’s getElementsByTagName(name) searches the whole tree, whereas the 
Element’s method searches only the sub-tree of the Element that it was called on.
normalize()
Parameters:
None
Return value
: None
Exceptions thrown
: None
Description
: Collapses adjacent Text nodes into one node. This view is reference as the 
normal form where only another type of node can separate a Text node.
Example
: If a programmer ended with a DOM tree as depicted in Figure 5.9, which can 
be done easily when moving nodes around, a call to normalize() on rootElement would 
produce the DOM tree shown in Figure 5.10.


- 134 -

Download 2,96 Mb.
1   ...   115   116   117   118   119   120   121   122   ...   131




Download 2,96 Mb.
Pdf ko'rish

Bosh sahifa
Aloqalar

    Bosh sahifa



var attrNode = xml.documentElement.getAttributeNode("myAttr")

Download 2,96 Mb.
Pdf ko'rish