Dim root As XElement = XElement.Load(xmlFile)
Dim stuff =
From item In root.Elements("abc") Select item
Debug.Print(stuff.Count)
XML的内容是:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<abc xmlns="foo">1</abc>
<abc xmlns="foo">2</abc>
<abc xmlns="foo">3</abc>
</Workbook>
如果我删除xmlns="urn:schemas-microsoft-com:office:spreadsheet"工作簿标记的开头,我会得到正确的结果3
ETA如果我嵌入了另一个命名空间,在本例中为“foo”,我该怎么办