我用google搜索了最后一个小时左右没有运气(我想我也是一个伟大的Google员工!),所以我在这里.
<?xml version="1.0" encoding="utf-8"?> <config> <store> <number>0323</number> <address>address</address> <phone>phone</phone> </store> <emailsettings> <emailfrom>emailfrom</emailfrom> <emailpass>pass</emailpass> <emailsubject>received</emailsubject> <smtpserver>smtp.gmail.com</smtpserver> <smtpport>587</smtpport> <enablessl>true</enablessl> <emailbody>package received</emailbody> </emailsettings> <dbconfig> <dbpath>path</dbpath> </dbconfig> </config>
如何使用vb.net获取每个元素并返回我想要的特定值?本身,我想返回< number> (在< store>下)在textBox1中,< emailbody> (在< emailsettings>下)在textBox2中.
帮助pleaseeeeee!谢谢 :)
啊,一个用Framework 3.5展示VB.NET强大的XML特性的完美例子:
原文链接:https://www.f2er.com/vb/255426.htmlSub Main() Dim xml = XDocument.Load("config.xml") Console.WriteLine("Number: " & xml.<config>.<store>.<number>.Value) Console.WriteLine("Body: " & xml.<config>.<emailsettings>.<emailbody>.Value) End Sub
收益率:
Number: 0323 Body: package received