如何从以下xml格式的文件中获取子元素
<?xml version="1.0" encoding="UTF-8"?>
<UserMenu Type="Company">
<li>Credit Card Details</li>
<li>Account Details</li>
<li>Disc Usage</li>
<li>Billing</li>
</UserMenu>
我希望输出为:
“信用卡详情” “帐户详细资料” “光盘使用” “结算”
答案 0 :(得分:1)
var doc = XDocument.Load(fileName);
var lis = (from e in doc.Descendants("li")
where e.Parent.Attribute("Type").Value == "Company"
select e.Value).ToArray();