嘛子值,這個人是我的XML文件的LINQ to XML:獲取元素
<?xml version="1.0" encoding="utf-8"?>
<config>
<setup>
<Test>10</Test>
<Copy>
<Descr>AA</Descr>
<Descr>BB</Descr>
</Copy>
</setup>
</config>
,這一個是我的LINQ查詢:(
Dim query = From q In XElement.Load("\MyXml.xml").Elements("setup") _
Where q.Element("Test").Value = "SomeValue" _
Select New With {.Test = q.Element("Test").Value, _
.CopyDescr = q.Element("Copy/Descr").Value}
不幸的是,這一次,產生以下直接的錯誤
The '/' character, hexadecimal value 0x2F, cannot be included in a name.
所以我的問題是,我怎麼能得到中包含的子值也沒有得到錯誤?您看到我很樂意將CopyDescr
中包含的值加載到List of(String)
以備後用......
在此先感謝!
是的,你要使用XPath表達式,但這無關使用XPath。 – 2011-03-02 16:04:12