/jonas skrebys/:

So when I use method e.getLastChild().getNodeValue() it returns null as I understand method setNodeValue("value") did not set the value to the last node <elemet-2>

If you follow the spec <http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-F68D080>:

nodeValue of type DOMString
The value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect, including if the node is read-only.

The "table above" defines:

Interface | nodeValue
----------+-----------
Element   | null

What you want could be achieved both ways:

1. Using DOM Level 1 interfaces, only:

   Element e = doc.createElement("element-1");
   Element e2 = e.appendChild(doc.createElement("element-2"));
   e2.appendChild(doc.createTextNode("value"));

2. Using the DOM Level 3 'Node.textContent' [1]:

   Element e = doc.createElement("element-1");
   Element e2 = e.appendChild(doc.createElement("element-2"));
   e2.setTextContent("value");

[1] http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent

--
Stanimir


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to