Sunday, May 22, 2011

Document to String

 DOMSource domSource = new DOMSource(document); //org.w3c.dom.Document document = null;  
 StringWriter writer = new StringWriter();  
 StreamResult result = new StreamResult(writer);  
 TransformerFactory tranFact = TransformerFactory.newInstance();  
 Transformer transfor = tranFact.newTransformer();  
 transfor.transform(domSource, result);  
 String returnXML=writer.toString();  

Add CDATA in JavaScript

 var newCdata=dataXmlDom.createCDATASection("data to append");  
 newContextElem.appendChild(newCdata);