【发布时间】:2020-06-01 19:47:39
【问题描述】:
我只想要一个使用 VB 的 XML 文件中的值。 XML文件是这样的
<?xml version="1.0" encoding="utf-8"?>
<Books>
<Book ID="12345">
<Name>One Flew Over The Cuckoo's Nest</Name>
<ISBN>Some cataloging ID</ISBN>
<Author>Ken Kesey</Author>
<More>Something here</More>
</Book>
</Books>
在此示例中,我只想获取作者为“Ken Kesey”的图书的 ISBN 号。我试过这个;
Dim xl As XElement = XElement.Load(AppDomain.CurrentDomain.BaseDirectory + "\Books.xml")
Dim Auth As String = From elem In xl.Elements("Books").Elements("Book")
Where elem.Element("ISBN").Value = "Some cataloging ID"
Select elem.Element("Author").Value
还有许多相同的变体,但没有效果。
感谢您的关注。
【问题讨论】: