This script converts simple XML string to DOM object.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> <%@ page import="javax.xml.parsers.*,org.w3c.dom.*,java.io.*,javax.xml.transform.*, javax.xml.transform.dom.*,javax.xml.transform.stream.*" %> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="GENERATOR" content="IBM WebSphere Studio"> <TITLE></TITLE> </HEAD> <BODY> <% String myXMLString = "<QN>Query</QN>" ; Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(myXMLString.getBytes("utf-8"))); NodeList list = doc.getElementsByTagName("QN"); out.println("No of element="+list.getLength()); for (int i=0; i<list.getLength(); i++) { Element element = (Element) list.item(i); out.println(" Tag Name="+element.getNodeName()); Text text1 = (Text) element.getFirstChild(); String str = text1.getData(); out.println(" Tag Value="+str); } %> </BODY> </HTML>