以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  求助生成XML  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=143042)

--  作者:keli0917
--  发布时间:2019/11/12 13:20:00
--  求助生成XML

要求将将AAA表中的数据按上传的XML格式生成XML文件。帮忙完美代码。

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:天亮专用.rar

[此贴子已经被作者于2019/11/12 13:21:17编辑过]

--  作者:有点蓝
--  发布时间:2019/11/12 14:17:00
--  
大概这样,细节自行补充完整

Dim tx As Table = Tables("AAA")
Dim ab As String = "91350200737855820M"
Dim cd As String = "专用发票"
Dim cnt,cnsp As Integer

cnsp = DataTables("AAA").Compute("Count([发票号码])","金额 > \'0\'")
Dim jo As New Foxtable.XObject
jo("body") = New JObject
jo("body")("head") = New JObject
jo("body")("head")("Rows") = cnsp
jo("body")("data") = New JObject
Dim ja As New JArray
\'jo("ink")=ja

Dim lst As List(of DataRow)=DataTables("AAA").Select("金额 > \'0\' ")
For i As Integer=0 To lst.count-1
    Dim kr As DataRow=lst(i)
    Dim j2 As New JObject
    j2("@id")= kr("序号").Tostring()
    j2("dm")=kr("发票代码").Tostring()
    j2("dm")=kr("发票代码").Tostring()
    j2("hm")=kr("发票号码").Tostring()
    j2("gf")=ab.Tostring()
    j2("xf")=kr("销方税号").Tostring()
    j2("kq")=kr("开票日期").Tostring()
    j2("je")=kr("金额").Tostring()
    j2("se")=kr("税额").Tostring()
    j2("rq")=kr("认证日期").Tostring()
    j2("lb")=cd.Tostring()
    ja.Add(j2)
Next
jo("body")("data")("row") = ja

Dim str As String  = jo.ToXML
\'Output.Show(str)


\'str = "<?xml version=""1.0"" encoding=""GBK"" ?> <!--DOCTYPE RZ00102 SYSTEM "RZ00102.dtd" -->  " & str & "</data></body>"
\'Output.Show(str)

Dim fl As String=ProjectPath & "Reports\\" & format(Date.today,"yyyyMMdd") & "发票数据XML" & ".xml"
If FileSys.FileExists(fl) Then
    FileSys.DeleteFile(fl)
End If
FileSys.WriteAllText(fl,str, True, Encoding.Default)

\'以下代码是用IE打开生成的xml
Dim proc As new Process
proc.file = ProjectPath & "Reports\\" & format(Date.today,"yyyyMMdd") & "发票数据XML"  & ".xml"
proc.Start