帮忙修改一下代码。谢谢
Dim xml As String = FileSys.ReadAllText(e.Form.Controls("TextBox1").value)
Dim xo As foxtable.XObject = foxtable.XObject.Parse(xml)
If xo.ToString()<>"" Then
For Each am As JToken In xo("Dec")("DecHead")
For Each bm As JToken In xo("Dec")("DecLists")("DecList")
Dim r As Row=Tables("报关单数据").addnew
r("项号")= bm("spxh")
r("商品代码") = bm("cmcode")
r("商品名称") = bm("cm_name")
r("币种") = bm("Yb_bz")
r("成交金额") = bm("yb_amt")
r("法定计量单位") = bm("Fd_unit")
r("法定数量") = bm("Fd_qnt")
r("第二计量单位") = bm("No2_Fd_unit")
r("第二数量") = bm("No2_Fd_qnt")
r("成交计量单位") = bm("Cj_unit")
r("成交数量") = bm("Cj_qnt")
r("海关报关单号") = am("bgd_no")
r("加工贸易手册号") = am("hgdjc_no")
r("出口收汇核销单号") = am("Hxd_no")
r("出口日期") = am("lj_date")
r("进出口合同号") = am("ht_no")
r("成交方式") = am("cj_type")
r("运费金额") = am("yf")
r("运费标志") = am("yf_type")
r("运费币种") = am("Yf_bz")
r("保费金额") = am("bf")
r("保费标志") = am("Bf_type")
r("保费币种") = am("Bf_bz")
r("杂费金额") = am("zf")
r("杂费标志") = am("Zf_type")
r("杂费币种") = am("Zf_bz")
r("海关贸易方式代码") = am("my_type")
r("运输工具") = am("traf_name")
Next
Next
End If
[此贴子已经被作者于2024/9/10 12:53:29编辑过]
奇怪,只能上传图片?
此主题相关图片如下:1.png
此主题相关图片如下:22.png
[此贴子已经被作者于2024/9/10 12:53:01编辑过]
XML文件
[此贴子已经被作者于2024/9/10 12:58:32编辑过]
If xo.ToString()<>"" Then
For Each am As JToken In xo("Dec")
For Each bm As JToken In am("DecLists")("DecList")
Dim r As Row=Tables("报关单数据").addnew
你好,当<DecLists>只有一个<DecList>时,就会出现以下异常。Cannot access child value on Newtonsoft.Json.Linq.JValue.
If xo.ToString()<>"" Then
For Each am As JToken In xo("Dec")
if am("DecLists")("DecList") is jarray then
For Each bm As JToken In am("DecLists")("DecList")
Dim r As Row=Tables("报关单数据").addnew
next
else
end if
next
end if
提示jarray是一个类型,不能用作表达式。