How to parse empty node value in Blackberry

前端 未结 2 1302
有刺的猬
有刺的猬 2021-01-29 00:46

I am getting the response from the web service as below


xxx

while pars

相关标签:
2条回答
  • 2021-01-29 01:01

    I tried the following code it workd

    speakersnode=speaker.getElementsByTagName("speaker");
    for(int k=0;k<speakersnode.getLength();k++)
    {
       String info;
        ids.addElement(((Element)speakersnode.item(k)).getAttribute("id"));
       try{
       info = speakersnode.item(k).getFirstChild().getNodeValue();
      }catch(NullPointerException e){info="";}
      vspeakers.addElement(info);
    }
    
    0 讨论(0)
  • 2021-01-29 01:21

    Try this:

    speakersnode=speaker.getElementsByTagName("speaker");
    for(int k=0;k<speakersnode.getLength();k++)
    {
       ids.addElement(((Element)speakersnode.item(k)).getAttribute("id"));
       String info = speakersnode.item(k).getFirstChild().getNodeValue();
       if (info == null){
           info = "";
       }     
       System.out.println("speaker "+ info );
       vspeakers.addElement(info);
    }
    

    You also need to learn how to debug. And how to handle exceptions. You will lear how to fix this kind of stuff in seconds

    0 讨论(0)
提交回复
热议问题