Javascript Reference
Categories: document

javascript document createTreeWalker( )

@March 15, 2008, 1:22 a.m.
createTreeWalker( ) Firefox/Netscape/NN 7 IE n/a Chrome/Safari/DOM 2

createTreeWalker(rootNode, whatToShow, filterFunction, entityRefExpansion)

Generates in memory an instance of a TreeWalker object.

 
Parameters
rootNode

Reference to a node in the document tree that becomes the first node in the TreeWalker object's list of nodes.

whatToShow

Integer value corresponding to one of several built-in filters that allow nodes of a single type to be included in the TreeWalker object returned by the method. The NodeFilter object contains constants that should be used as plain-language substitutes for this value:

NodeFilter.SHOW_ALLNodeFilter.SHOW_ATTRIBUTE
NodeFilter.SHOW_CDATA_SECTIONNodeFilter.SHOW_COMMENT
NodeFilter.SHOW_DOCUMENTNodeFilter.SHOW_DOCUMENT_FRAGMENT
NodeFilter.SHOW_DOCUMENT_TYPENodeFilter.SHOW_ELEMENT
NodeFilter.SHOW_ENTITYNodeFilter.SHOW_ENTITY_REFERENCE
NodeFilter.SHOW_NOTATIONNodeFilter.SHOW_PROCESSING_INSTRUCTION
NodeFilter.SHOW_TEXT
filterFunction

Reference to a user function that can further filter nodes that are included in the TreeWalker object. The function has a single parameter (a reference to a node to test, invoked automatically by the TreeWalker object). The value returned by the function determines whether the node being tested is to be included in the list of nodes. Returned values are integers, but the NodeFilter object provides three constants you should use as plain-language substitutes:

NodeFilter.FILTER_ACCEPTNodeFilter.FILTER_REJECT
NodeFilter.FILTER_SKIP

With a return value of NodeFilter.FILTER_SKIP, descendant nodes of the skipped node may still qualify as members of the TreeWalker node list (provided they survive other filtering). A return value of NodeFilter.FILTER_REJECT removes both the node under test and its descendants from consideration as members of the TreeWalker object. See the TreeWalker object for an example of this kind of function.

entityRefExpansion

Boolean value that controls whether the content of entity reference nodes (found predominantly in XML documents) should be treated as hierarchical nodes (true) or not (false).

 
Returned Value

TreeWalker object reference.

Under moderation.
Raymondhob - 2015-01-13

Powered by Linode.