以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]用UDPClient与网站通讯代码编写  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=93073)

--  作者:dszqiooe
--  发布时间:2016/11/19 22:54:00
--  [求助]用UDPClient与网站通讯代码编写
本人想用foxtabel的UDPClient功能与网站通讯,将返回结果合并到PLANT表中。请问各位大神,把返回值解析并合并到表格的代码怎么写啊???

例子:

IP:http://www.w3school.com.cn/example/xmle/plant_catalog.xml
Port:未知

用浏览器打开IP后部分返回值如下:

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20161119230001.png
图片点击可在新窗口打开查看

[此贴子已经被作者于2016/11/19 22:57:35编辑过]

--  作者:dszqiooe
--  发布时间:2016/11/19 23:02:00
--  
请大家帮帮忙图片点击可在新窗口打开查看
--  作者:有点青
--  发布时间:2016/11/20 9:28:00
--  

参考代码

 

Dim xmlDoc As New System.XML.XmlDocument
xmlDoc.Load("d:\\test.xml")
Dim ndList  = xmlDoc.GetElementsByTagName("PLANT")

For i As Integer = 0 To ndList.count - 1
    Dim COMMON As String = ndList(i).Item("COMMON").InnerText
    Dim BOTANICAL As String = ndList(i).Item("BOTANICAL").InnerText
    Dim ZONE As String = ndList(i).Item("ZONE").InnerText
   
    output.show(COMMON & " " & BOTANICAL & " " & ZONE)
Next


--  作者:dszqiooe
--  发布时间:2016/11/20 16:27:00
--  
以下是引用有点青在2016/11/20 9:28:00的发言:

参考代码

 

Dim xmlDoc As New System.XML.XmlDocument
xmlDoc.Load("d:\\test.xml")
Dim ndList  = xmlDoc.GetElementsByTagName("PLANT")

For i As Integer = 0 To ndList.count - 1
    Dim COMMON As String = ndList(i).Item("COMMON").InnerText
    Dim BOTANICAL As String = ndList(i).Item("BOTANICAL").InnerText
    Dim ZONE As String = ndList(i).Item("ZONE").InnerText
   
    output.show(COMMON & " " & BOTANICAL & " " & ZONE)
Next


请问如何将http://www.w3school.com.cn/example/xmle/plant_catalog.xml网页内容保存为d:\\test.xml呢?



--  作者:有点青
--  发布时间:2016/11/20 18:08:00
--  

参考代码

 

Dim msg As String = ""
Dim req = System.Net.WebRequest.Create("http://www.w3school.com.cn/example/xmle/plant_catalog.xml")
req.Method = "get"

Dim pos = req.GetResponse
Dim stm As System.IO.Stream = pos.GetResponseStream()
Dim reader As New System.IO.StreamReader(stm)
Dim str As String = reader.ReadToEnd

pos.Close
stm.Close
reader.close

\'output.show(str)
 

Dim xmlDoc As New System.XML.XmlDocument
xmlDoc.Loadxml(str)
Dim ndList  = xmlDoc.GetElementsByTagName("PLANT")

For i As Integer = 0 To ndList.count - 1
    Dim COMMON As String = ndList(i).Item("COMMON").InnerText
    Dim BOTANICAL As String = ndList(i).Item("BOTANICAL").InnerText
    Dim ZONE As String = ndList(i).Item("ZONE").InnerText
   
    output.show(COMMON & " " & BOTANICAL & " " & ZONE)
Next


--  作者:dszqiooe
--  发布时间:2016/11/20 23:48:00
--  
测试有效,谢谢!