[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to get Node value In a DOM Tree
Hello Techies, I am trying to create a DOM Tree. I had create Node's for the DOM Tree. I want to know how to set the Values to these Nodes. Element root = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.newDocument(); root = document.createElement(Root_Element); document.appendChild(root); Element applicationElement =document.createElement(Application_Element); applicationElement.setNodeValue("krish"); root.appendChild(applicationElement); Now when I try to get the This Node Value , I am getting null Pointer Exception. Here is my code of retrieving the node value NodeList applicationNodeList = null; applicationNodeList =finalElement.getElementsByTagName("application"); System.out.println("applicationNodeList size"+applicationNodeList.getLength()); for(int i = 0; i<= applicationNodeList.getLength();i++) { System.out.println("eachApplicaiton in the DOM"+applicationNodeList.item(i).getNodeValue()); } I am getting NodeList size is 1 , but I the node Value I am getting as Null. What I am doing for setting the Node Value is correct(or) am I missing some thing. Can u guys help me out to fix this problem. regards,
ramu
Yahoo! India Answers: Share what you know. Learn something new http://us.rd.yahoo.com/mail/in/mailanswersshare/*http://in.answers.yahoo.com/ Send free SMS to your Friends on Mobile from your Yahoo! Messenger http://us.rd.yahoo.com/mail/in/freesms/*http://messenger.yahoo.com/download.php
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|