Read XML in VB.net

后端 未结 4 1586
情歌与酒
情歌与酒 2021-02-09 08:45

I have googled for the last hour or so with no luck (I\'d like to think I\'m a great googler too!), so here I am.

I have an XML file that I\'m using for my programs sett

4条回答
  •  执笔经年
    2021-02-09 09:43

    Here's a Console app using the VB.Net XML Literal support.

    Module Module1
    
        Sub Main()
    
            Dim xElem = 
                           
                               0323
                               
    address
    phone
    emailfrom pass received smtp.gmail.com 587 true package received path
    Dim number = xElem...Value Dim emailbody = xElem...Value Console.WriteLine(String.Format("Number={0}", number)) Console.WriteLine(String.Format("emailbody={0}", emailbody)) Console.ReadLine() '--- What it'd look like if you loaded from a file using XDocument.Load Dim xDoc = XDocument.Load(New IO.StringReader(xElem.ToString)) number = xDoc.Root...Value emailbody = xDoc.Root...Value Console.WriteLine(String.Format("Number={0}", number)) Console.WriteLine(String.Format("emailbody={0}", emailbody)) Console.ReadLine() End Sub End Module

    The results will be:

    Number=0323
    emailbody=package received
    
    Number=0323
    emailbody=package received
    

提交回复
热议问题