改为从文件中读取;因此,我演示了如何使用System.Xml.Linq.XDocument.Parse加载XDocument。我想使我的示例简洁,但要包含实际的XML,这样它就可以成为一个完全有效的示例。 ' this gets the value of
改为从文件中读取;因此,我演示了如何使用System.Xml.Linq.XDocument.Parse加载XDocument。我想使我的示例简洁,但要包含实际的XML,这样它就可以成为一个完全有效的示例。改为从文件中读取;因此,我演示了如何使用System.Xml.Linq.XDocument.Parse加载XDocument。我想使我的示例简洁,但要包含实际的XML,这样它就可以成为一个完全有效的示例。 ' this gets the value of ,xml,vb.net,linq,linq-to-xml,Xml,Vb.net,Linq,Linq To Xml,改为从文件中读取;因此,我演示了如何使用System.Xml.Linq.XDocument.Parse加载XDocument。我想使我的示例简洁,但要包含实际的XML,这样它就可以成为一个完全有效的示例。 ' this gets the value of the price element within a product product.<Price>.Value Public Class Product Property Description As String
' this gets the value of the price element within a product
product.<Price>.Value
Public Class Product
Property Description As String
Property Price As Double
Public Shared Function FromXml(serverPath As String) As IEnumerable(Of Product)
Using fs = IO.File.OpenRead(serverPath)
Dim p As New Product
Return New XmlSerializer(p.GetType).Deserialize(fs)
End Using
End Function
End Class
dim listOfProducts = Product.FromXml(Server.MapPath("~/App_Data/products.xml"))