import java.io.StringWriter;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
public class Main {
public static void main(String[] argv) throws Exception {
}
static String getXMLString(Document xmlDoc) throws Exception {
StringWriter writer = null;
DOMSource source = new DOMSource(xmlDoc.getDocumentElement());
writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.transform(source, result);
StringBuffer strBuf = writer.getBuffer();
return strBuf.toString();
}
}
sources68 the directory containing the programming examples, source code and programming guide online
Tuesday, 2 August 2011
Extracting an XML formatted string out of a DOM object
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment