OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   How to get Node value In a DOM Tree

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev@lists.xml.org
  • Subject: How to get Node value In a DOM Tree
  • From: Seetha Rama Krishna <ram_kurra@yahoo.co.in>
  • Date: Wed, 31 May 2006 14:52:03 +0100 (BST)
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=fwsPpg2YsaHqb4+fgVHupooTggLDEUXSaX0j85SOi9JJPv6ar4p8p6fjyQqCM4IQP7aWUrdTQeiGXFMZujj0yBsuT34Fr6JxRm9uxOj4TBvDb5CAj96L1Aienw3FeQdQprizyw2TKg8iQgi4sqOfjVqYxSUczk0H4jfvhsbBd7o= ;

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 Click here
Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download now



 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS