Foxtable(狐表)用户栏目专家坐堂 → [求助]关于XML


  共有2239人关注过本帖树形打印复制链接

主题:[求助]关于XML

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/21 17:59:00 [显示全部帖子]

参考代码

 

Dim dlg As new OpenFileDialog
If dlg.ShowDialog = DialogResult.OK Then
    Dim txt As String = FileSys.ReadAllText(dlg.FileName, Encoding.Default)
    Dim idx1 As Integer = txt.IndexOf("<Events")
    Dim idx2 As Integer = txt.IndexOf("</Events>")
   
    Dim s As String = txt.SubString(idx1, idx2-idx1+9)
    Dim xmlDoc As New System.XML.XmlDocument
    xmlDoc.Loadxml(s)
    Dim ndList  = xmlDoc.GetElementsByTagName("Code")
   
    For i As Integer = 0 To ndList.count - 1
        Dim curCode As String = ndList(i).Attributes("curCode").value
        Dim packLayer As String = ndList(i).Attributes("packLayer").value
        Dim flag As String = ndList(i).Attributes("flag").value
        output.show(curCode & " " & packLayer & " " & flag)
    Next
   
End If


 回到顶部