How to avoid encoding of <,>,& with Document.createTextNode

mrc

New Member
\[code\]class XMLencode { public static void main(String[] args) { try{ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element root = doc.createElement("roseindia"); doc.appendChild(root); Text elmnt=doc.createTextNode("<data>sun</data><abcdefg/><end/>"); root.appendChild(elmnt); TransformerFactory tranFactory = TransformerFactory.newInstance(); Transformer aTransformer = tranFactory.newTransformer(); Source src = http://stackoverflow.com/questions/12525152/new DOMSource(doc); Result dest = new StreamResult(System.out); aTransformer.transform(src, dest); }catch(Exception e){ System.out.println(e.getMessage()); } }}\[/code\]Here is my above piece of code.The output generated is like this\[code\]<?xml version="1.0" encoding="UTF-8" standalone="no"?><roseindia><data>sun</data><abcdefg/><end/></roseindia>\[/code\]I dont want the tags to be encoded. I need the output in this fashion.\[code\]<?xml version="1.0" encoding="UTF-8" standalone="no"?><roseindia><data>sun</data><abcdefg/><end/></roseindia>\[/code\]Please help me on this.Thanks,Mohan
 
Back
Top