简体   繁体   English

如何从asp.net中的vb.net中的自关闭xml元素提取信息?

[英]How to extract information from self-closing xml elements in vb.net in asp.net?

For example, 例如,

<Image><URL scope="public" type="string" value"image URL"/></Image>

I want to extract image URL(value of URL) from this element and display the image. 我想从此元素中提取图像URL(URL的值)并显示图像。 How can i do that? 我怎样才能做到这一点?

You may use XDocument ( LINQ-to-XML ): 您可以使用XDocumentLINQ-to-XML ):

Dim url As String = XDocument.Load(new StringReader("<Image><URL scope=\"public\" type=\"string\" value=\"image URL\"/></Image>")).Descendants("URL").Attribute("value").Value

Check the XDocument.Load(TextReader) method overload documentation. 检查XDocument.Load(TextReader)方法重载文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM