[
Lists Home |
Date Index |
Thread Index
]
probably just need to check if it has a value before you do something with it:
if (chhh.getFirstChild().getNodeValue()) {
//do a print
System.out.println("NodeType 1" +chhh.getFirstChild().getNodeValue());
applicationArrayList.add(chhh.getFirstChild().getNodeValue());
}
On 6/7/06, Seetha Rama Krishna <ram_kurra@yahoo.co.in> wrote:
> Hi,
> I am having an xml file like the following
> <application>
> <row>
> <id>4</id>
> <name>CLIENTDEMO</name>
> <description/>
> </row>
> </application>
> I had written java code to iterate thru this xml and retrieve the
> values . when the element <description> came I am getting null pointer
> xception.
>
> Here is my code.
> NodeList application =
> documentElement.getElementsByTagName("application");
> for (int i = 0; i < application.getLength(); i++)
> {
>
> NodeList nl = application.item(i).getChildNodes();
> {
> Node ch = application.item(i);
> NodeList nll = ch.getChildNodes();
> ArrayList applicationArrayList = new ArrayList();
> for (int j = 0; j < nll.getLength(); j++)
> {
> Node chh = nl.item(j);
> NodeList nlll = chh.getChildNodes();
> //System.out.println("Animals = " + nlll.getLength());
>
> for (int k = 0; k < nlll.getLength()-1; k++)
> {
> Node chhh = nlll.item(k);
> System.out.println("NodeType 1"+
> chhh.getNodeType());
> if (chhh.getNodeType() == 1)
> {
> System.out.println("NodeType 1"+
> chhh.getNodeName());
> System.out.println("NodeType 1"
> +chhh.getFirstChild().getNodeValue());
>
> applicationArrayList.add(chhh.getFirstChild().getNodeValue());
>
> }
>
> }
>
> }
>
>
> }
>
>
> }
>
> How can I skip when i get null values in the xml??
>
>
>
>
>
> regards,
> ramu
>
> Send instant messages to your online friends http://in.messenger.yahoo.com
>
> Stay connected with your friends even when away from PC. Link:
> http://in.mobile.yahoo.com/new/messenger/
--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html
|