Null Pointer Exception in XMl Parsing

前端 未结 4 649
礼貌的吻别
礼貌的吻别 2021-01-13 23:00

I need to parser an Xml Document and store the values in Text File, when i am parsing normal data (If all tags have data) then its working fine, but if any tag doesnt have d

4条回答
  •  迷失自我
    2021-01-13 23:25

    Replace

    System.out.println("First Name : " + getTagValue("firstname", eElement));
    

    by

    System.out.println("First Name : " + getTagValue("firstname", eElement) == null?"":getTagValue("firstname", eElement));
    

    same thing for the other tags.

提交回复
热议问题