以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请教xml  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=83655)

--  作者:hbhb
--  发布时间:2016/4/13 23:30:00
--  请教xml
大师:请问如何根据一张表(一列元素、一列属性、一列文本)的内容,代码写xml的文档?
--  作者:Hyphen
--  发布时间:2016/4/14 8:20:00
--  
看看http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=80579
--  作者:大红袍
--  发布时间:2016/4/14 9:27:00
--  

Dim str As String = ""
Dim cs() As String = {"第一列", "第二列"}
str &= "<root>"
For Each r As Row In Tables("表a").rows
    str &= "<表A>"
    For Each c As String In cs
        str &= "<" & c & ">" & r(c) & "</" & c & ">"
    Next
    str &= "</表A>"
Next
str &= "</root>"
msgbox(str)

Dim doc As New System.XML.XmlDocument()
doc.LoadXml(str)
Dim stream As new System.Io.FileStream("d:\\test.xml", System.Io.FileMode.OpenOrCreate, System.Io.FileAccess.Write)
doc.Save(stream)
stream.Close()


--  作者:hbhb
--  发布时间:2016/4/14 20:07:00
--  
谢谢!用ie打开,但验证错误。何原因?
--  作者:大红袍
--  发布时间:2016/4/14 20:16:00
--  

Dim str As String = ""
Dim cs() As String = {"第一列", "第二列"}
str &= "<?xml version=""1.0"" standal"?>" & vbcrlf
str &= "<DocumentElement>"
For Each r As Row In Tables("表a").rows
    str &= "<表A>"
    For Each c As String In cs
        str &= "<" & c & ">" & r(c) & "</" & c & ">"
    Next
    str &= "</表A>"
Next
str &= "</DocumentElement>"
msgbox(str)

FileSys.WriteAllText("d:\\test.xml", str, False, Encoding.utf8)


--  作者:hbhb
--  发布时间:2016/4/14 20:31:00
--  
str &= "<?xml version=""1.0"" standal"?>" & vbcrlf   只一句显示“字符无效”?
--  作者:大红袍
--  发布时间:2016/4/14 20:33:00
--  

Dim str As String = ""
Dim cs() As String = {"第一列", "第二列"}
str &= "<?xml version=""1.0"" standalone=""yes""?>" & vbcrlf
str &= "<DocumentElement>"
For Each r As Row In Tables("表a").rows
    str &= "<表A>"
    For Each c As String In cs
        str &= "<" & c & ">" & r(c) & "</" & c & ">"
    Next
    str &= "</表A>"
Next
str &= "</DocumentElement>"
msgbox(str)

FileSys.WriteAllText("d:\\test.xml", str, False, Encoding.utf8)

 


--  作者:hbhb
--  发布时间:2016/4/14 20:42:00
--  
谢谢!如果第二列内容作为第一列元素的属性,该怎么写代码?
--  作者:大红袍
--  发布时间:2016/4/14 20:43:00
--  

自己合并字符串,合并成自己需要的字符串。代码自己写。


--  作者:hbhb
--  发布时间:2016/4/14 20:59:00
--  
可惜我是一颗小草加羽毛未全的菜鸟呀,写一年预计都写不出来!可伶可伶小小鸟吧!!!!!!