This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Here i found package org.w3c.dom very uncomfortable..at the same time i came to know JDOM is now almost obsolete. During my attempt i faced problem
saying class cast exception com.sun.org.apache.xerces.internal.dom.DeferredTextImpl...
Please suggest me approach to tackle such type of problem.
Any limitations to use JAXP DOM ? except if your XML is too large.
1) You can search the element by getElementsByTagName 2) Then change the node value by creating new element
Element newNode = document.createElement("userName");
newNode.setTextContent(""); // new Node value ;
3) replace this element in the XML parent element
4) Write the changed DOM to a new XML or overwrite to same xml.
using Transformer object transform method.
Joined: Jan 22, 2008
Thanks a ton Balu
A very simple but effective approach.