Resin 1.1
FAQ
Reference
JavaDoc
Demo
Java Tutorial
Getting Started
Configuration
Servlet
JSP
XTP/XSL
JavaScript
JS Library
Core Library
File Library
Servlet Library
Database Library
XML Library
Parser
XQL
XSL
Document
Node
Element
Text
Comment
EntityRef
CData
PI
XML Node
Node
nodeName | Returns name of the node, e.g. an element's tag name.
nodeValue | Returns the node's value, e.g. an attribute value.
nodeType | Returns the node type.
parentNode | Returns the parent node.
firstChild | Returns the first child node.
lastChild | Returns the last child node.
previousSibling | Returns the previous node.
nextSibling | Returns the next node.
childNodes | Returns a `NodeList` of the children.
ownerDocument | Returns the `Document` object of this node.
cloneNode(deep) | Returns a copy of the node.
insertBefore(newNode, refNode) | Inserts newNode as a child of this node, before refNode.
replaceChild(newNode, refNode) | Replaces refNode with newNode as a child of this node.
removeChild(refNode) | Removes refNode as a child of this node.
appendChild(newNode) | Adds newNode as the last child of this node.
find(pattern) | Returns the first node matching the XPath pattern.
select(pattern) | Returns an iteration of nodes matching the XPath pattern.
print(stream) | Writes the XML representation of this node and its children to stream
Node | DOM 1.0
### nodeName
Returns name of the node, e.g. an element's tag name.
### nodeValue
Returns the node's value, e.g. an attribute value.
### nodeType
Returns the node type.
ELEMENT_NODE | <sample/>
TEXT_NODE | some text
COMMENT_NODE | <!-- a comment -->
ATTRIBUTE_NODE | an element attribute
CDATA_SECTION_NODE | <[CDATA[[<random stuff]]>
PROCESSING_INSTRUCTION_NODE | <?name data?>
### parentNode
Returns the parent node.
### firstChild
Returns the first child node.
xml = caucho.xml.Xml.parseString("<a><b/><c/><d/></a>"); top = xml.documentElement for (var child = top.firstChild; child; child = child.nextSibling) { writeln(child.nodeName); }
b c d
### lastChild
Returns the last child node.
xml = caucho.xml.Xml.parseString("<a><b/><c/><d/></a>"); top = xml.documentElement for (var child = top.lastChild; child; child = child.previousSibling) { writeln(child.nodeName); }
d c b
### previousSibling
Returns the previous node.
### nextSibling
Returns the next node.
### childNodes
Returns a `NodeList` of the children.
xml = caucho.xml.Xml.parseString("<a><b/><c/><d/></a>"); top = xml.documentElement for (var child in top.childNodes) { writeln(child.nodeName); }
d c b
### ownerDocument
Returns the `Document` object of this node.
### cloneNode(deep)
Returns a copy of the node.
### insertBefore(newNode, refNode)
Inserts newNode as a child of this node, before refNode. If refNode is null, appends newNode as the last child.
xml = caucho.xml.Xml.parseString("<top><a/><top>") top = xml.documentElement foo = xml.createElement("foo"); top.insertBefore(foo, top.firstChild); top.print(out)
<top><foo/><a/></top>
### replaceChild(newNode, refNode)
Replaces refNode with newNode as a child of this node.
xml = caucho.xml.Xml.parseString("<top><a/><top>") top = xml.documentElement foo = xml.createElement("foo"); top.replaceChild(foo, top.firstChild); top.print(out)
<top><foo/></top>
### removeChild(refNode)
Removes refNode as a child of this node.
xml = caucho.xml.Xml.parseString("<top><a/><top>") top = xml.documentElement top.removeChild(top.firstChild); top.print(out)
<top/>
### appendChild(newNode)
Adds newNode as the last child of this node.
xml = caucho.xml.Xml.parseString("<top><a/><top>") top = xml.documentElement foo = xml.createElement("foo"); top.appendChild(foo) top.print(out)
<top><a/><foo/></top>
### find(pattern) | ### Resin 1.0
Returns the first node matching the XPath pattern. `find` returns `null` if no nodes match. `find` matches nodes based on the powerful XML Path Language. XPath forms the basis of XSL, the XML style language. The following example finds the first descendent link with an `href` attribute of www.caucho.com.
link = node.find(".//a[@href='www.caucho.com']")
### select(pattern) | ### Resin 1.0
Returns an iteration of nodes matching the XPath pattern. The following example selects all the descendant images, essentially the same as getElementsByTagName.
for (var image in node.select(".//image")) writeln("image: " + image.attribute.href)
### print(stream) | ### Resin 1.0
Writes the XML representation of this node and its children to stream Note: This is an experimental API.
xml = caucho.xml.Xml.parseString(@<<END); <top> <foo a='1'/> <foo a='2'> <foo a='3'/> </foo> </top> END xml.print(out)
<top> <foo a="1"/> <foo a="2"> <foo a="3"/> </foo> </top>
Document |  | Element
Copyright © 1998-2000 Caucho Technology. All rights reserved. Last modified: Fri, 31 Mar 2000 18:57:25 -0800 (PST)