<title section="Resin : XML Tutorial : ">
Text
</title>

<p/><var/Text/> nodes, like elements, are children of nodes.  The text
value is retrieved using <var/getNodeValue()/>.

<section title="Adding Text Nodes">

<p/>Text nodes are added using the <var/appendChild()/> call, like Elements.

<example title="Resulting XML">
&lt;top>Hello, world&lt;/top>
</example>

<example title="Adding Attributes with the DOM">
// Create a new document
Document doc = builder.newDocument();

// Create the top element
Element top = doc.createElement("top");

// Create Text Node
Text text = doc.createTextNode("Hello, world");

// Add it to the top
top.appendChild(text);
</example>

</section>

<section title="Getting Text Values">

<p/>As mentioned above, the value of a text node is retrieved using
<var/getNodeValue()/>.  The <var/name/> of a text node is
always <var/#text/>.  Normally, you'll either use <var/instanceof/> or
<var/getNodeType()/> to tell if the node is a text node, but testing
the <var/name/> against <var/#text/> will work.

<p/>The following function recursively prints all the text children
of an element.  It tests against <var/CharacterData/> so <var/CDATA/>
sections will also be printed.

<example>
void printText(Node node)
{
  for (; node != null; node = node.getNextSibling()) {
    if (node instanceof CharacterData)
      System.out.print(ptr.getNodeValue());

    printText(node.getFirstChild());
  }
}
</example>

</section>

