当前位置: 代码迷 >> PB >> xmldom 解析xml的有关问题 如何判断空值
  详细解决方案

xmldom 解析xml的有关问题 如何判断空值

热度:231   发布时间:2016-04-29 09:36:14.0
xmldom 解析xml的问题 怎么判断空值
各们老大我现在解析xml文件是一个比如row 10 column 18 的文件但列值有空值就在用下面编时运到到 ls_name = inewnode1.childnodes[0].nodevalue
这行时只要有空值就出错我现在想有没有办处理或判断如是空值就不执行这一句也可以.....在此谢谢了
原文件:<?xml version='1.0' encoding='gb2312'?><function><function_id>UpdateLeechdom</function_id><out_code>000</out_code><out_text>执行成功</out_text><data rowcount="1" columns="18"><row rownum="0"><column colnum="0" colname="insureId">919300000405</column><column colnum="1" colname="classNo">0103</column><column colnum="2" colname="grade">1</column><column colnum="3" colname="name">09断血流颗粒新款</column><column colnum="4" colname="spec">1*1</column><column colnum="5" colname="conf"></column><column colnum="6" colname="unit"></column><column colnum="7" colname="price">0.0</column><column colnum="8" colname="everyMoney">0.0</column><column colnum="9" colname="ratio">1.0</column><column colnum="10" colname="adminLevel">0</column><column colnum="11" colname="isClinic">1</column><column colnum="12" colname="remark">测试用</column><column colnum="13" colname="inputPyCode">dxlkl</column><column colnum="14" colname="updateTime">2009-04-01 00:00:00.0</column><column colnum="15" colname="inputWbCode"></column><column colnum="16" colname="approveMaxPrice"></column><column colnum="17" colname="approveMaxPrice"></column></row></data></function>


程序编码:
string ls_lasdate,return_status,return_mes
string ls_return,ls_name
oleobject ixmldom,root
oleobject inewnode
oleobject inewnode2
oleobject inewnodelist,inewnodelist1,inewnodelist2
oleobject inewnode1
boolean lb_tf
int ll_1
long ls_length,li_l
integer i,j,li_i
string ls_a,ls_kh
string Ls_b,ls_s
long ll_new
ls_lasdate= '2009-03-25 12:00:00'
ls_return = updateLeechdom(ls_lasdate,gs_nhcs.centerno)
debugbreak()
ixmldom = create oleobject
ll_1 = ixmldom.connecttonewobject("microsoft.xmldom")

if ll_1 <> 0 then
messagebox("error","create object fail")
else
lb_tf = ixmldom.loadxml(ls_return)
inewnode = ixmldom.selectsinglenode("//out_code")
if isnull(inewnode) then
messagebox("提示!","没找到患者信息!!")
return
end if
return_status =inewnode.text
return_mes = ixmldom.selectsinglenode("//out_text").text
end if
if return_status = "000" then
root = ixmldom.documentelement
inewnodelist = root.getelementsbytagname("row")
ls_length = inewnodelist.length
  dw_2.reset()
for i = 0 to ls_length - 1
inewnodelist1 = inewnodelist.item[i]
inewnodelist2 = inewnodelist1.getelementsbytagname("column")
li_l = inewnodelist2.length
ll_new = dw_2.insertrow(0)

for j = 0 to 5 - 1
inewnode1 = inewnodelist2.item[j]
ls_name = inewnode1.childnodes[0].nodevalue
  choose case j
case 0
dw_2.setitem(ll_new,"insureid",ls_name)
case 1
dw_2.setitem(ll_new,"classno",ls_name)
case 2
dw_2.setitem(ll_new,"grade",ls_name)
case 3
dw_2.setitem(ll_new,"name",ls_name)
case 4
dw_2.setitem(ll_new,"spec",ls_name)
case 5
dw_2.setitem(ll_new,"conf",ls_name)