In this illustration, we will discuss about the appending the value to the node in XML document.
The createTextNode() method creates a new Text for the specified node as the document element for Text node.
DocumentBuilderFactory class is used to create new DOM parsers and DocumentBuilder is used in code given below for creating an Blank DOM Document.
The following code is used to create a textNode.
Text childElement = doc.createTextNode("string");
Here is the full code of createTextNodeExample.java
Output:
| C:\>javac createTextNodeExample.java C:\>java createTextNodeExample <?xml version="1.0" encoding="UTF-8" standalone="no"?> <roseindia> Employee:spring </roseindia> |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.