以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  这个xml文件有啥问题,为啥读取不到数据?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=186192)

--  作者:sloyy
--  发布时间:2023/4/12 9:44:00
--  这个xml文件有啥问题,为啥读取不到数据?
Dim ssCODE,ssMsg,fphm,fpdm As String
Dim xmlDoc As New System.XML.XmlDocument
xmlDoc.Load(ProjectPath & "Attachments\\返回数据.xml")

Dim ndList As System.XML.XmlNodeList = xmlDoc.GetElementsByTagName("business")

For i As Integer = 0 To ndList.count - 1
    ssCode=ndList(i).item("returncode").InnerText
    ssMsg =ndList(i).item("returnmsg").InnerText

    If sscode="0" Then
        fphm=ndList(i).item("fphm").InnerText
        fpdm=ndList(i).item("fpdm").InnerText
    End If
Next
MessageBox.Show(fphm)

--  作者:sloyy
--  发布时间:2023/4/12 9:45:00
--  
<?xml version="1.0" encoding="gbk"?>
<business id="10008" comment="发票开具">
<body yylxdm="1">
<returncode>0</returncode>
<returnmsg>成功</returnmsg>
<returndata>
<fpdm>045002200104</fpdm>
<fphm>07190389</fphm>
</returndata>
</body>
</business>

--  作者:有点蓝
--  发布时间:2023/4/12 9:57:00
--  
要根据结构一层一层的取数据

For i As Integer = 0 To ndList.count - 1
    ssCode = ndList(i).item("body").item("returncode").InnerText
    ssMsg = ndList(i).item("body").item("returnmsg").InnerText

    If sscode = "0" Then
        fphm = ndList(i).item("body").item("returndata").item("fphm").InnerText
        fpdm = ndList(i).item("body").item("returndata").item("fpdm").InnerText
    End If
Next

--  作者:sloyy
--  发布时间:2023/4/12 23:23:00
--  
我明白了,这个xml文件的结构是多层的,和以前的xml文件不一样,大意了,没有闪图片点击可在新窗口打开查看