You need setTextContent(String textContent) method and not setAttribute
method.
root.getElementsByTagName("date").item(0).setTextContent("newValue");
oldValue
is the TextContent
of <date>
element, not attribute. Check here to find what is attribute.