vb.net LINQ TO XML读写XML

vb.net LINQ TO XML读写XML,第1张

概述1Imports System.Linq  2Imports System.Xml.Linq  3  4Public Class xmlDemoClass xmlDemo  5    Public Shared Sub CreateXml()Sub CreateXml()  6        Dim ld As New List(Of Object)  7        ld.Add(New Wi 1imports System.linq
2imports System.Xml.linq
3
4Public Class xmlDemoClass xmlDemo
5 Public Shared Sub CreateXml()Sub CreateXml()
6 Dim ld As New List(Of Object)
7 ld.Add(New With {.ID = "1",.name = "人事"})
8 ld.Add(New With {.ID = "2",.name = "业务"})
9
10
11 Dim lp As New List(Of Object)
12 lp.Add(New With {.ID = "1",.name = "jim",.DID = "1"})
13 lp.Add(New With {.ID = "2",.name = "tony",.DID = "2"})
14 lp.Add(New With {.ID = "3",.name = "jesson",Arial; line-height:26px">15
16
17 Dim person =
18 <%= From p In lp Where p.ID _
19 Select
20<%= p.ID %>
21<%= p.name %>
22%>
23
24
25 person.Save("C:\persons.xml")
26 Process.Start("C:\persons.xml")
27
28 Dim departMent =<%= From d In ld _
29 Select
30<%= d.ID %>
31<%= d.name %>
32
33 <%= From p In lp Where p.dID = d.ID _
34 Select
35<%= p.ID %>
36<%= p.name %>
37%>
38
39%>
40
41 departMent.Save("c:\departMent.xml")
42 Process.Start("c:\departMent.xml")
43
44
45 End Sub
46 Public Shared Sub readxml()Sub readxml()
47
48 Dim xdoc = Xdocument.Load("C:\persons.xml")
49 Dim ps = From p In xdoc.Descendants("person") _
50 Select New With {.ID = p.Element("ID").Value,.name = p.Element("name").Value}
51 For Each p In ps
52 MsgBox(p.ID & Space(3) & p.name)
53 Next
54 End Sub
55End Class 总结

以上是内存溢出为你收集整理的vb.net LINQ TO XML读写XML全部内容,希望文章能够帮你解决vb.net LINQ TO XML读写XML所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1265960.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存