Ulf, I have one more problem now . After generating and populating the XML, from other part of my program I need to read the text in each element node. and i tried using the below code NodeList var1 = doc.getElementsByTagName("optionsIndex"); Element ele1 = (Element)var1.item(0); NodeList text1 = ele1.getChildNodes();// here String optionsIndexString = ((Node)text1.item(0)).getNodeValue(); But on the line marked 'here' I ...