我有这个 XML 文档:
<?xml version="1.0" encoding="utf-8"?>
<directoryresponse xmlns="https://www.sisow.nl/Sisow/REST" version="1.0.0">
<directory>
<issuer>
<issuerid>01</issuerid>
<issuername>ABN Amro Bank</issuername>
</issuer>
<issuer>
<issuerid>02</issuerid>
<issuername>ASN Bank</issuername>
</issuer>
</directory>
</directoryresponse>
这不起作用:
var banks = doc.Descendants("issuer").Select(x =>
new Bank(Convert.ToInt32(x.Element("issuerid").Value), x.Element("issuername").Value)).ToList();
但是当我手动删除 directoryresponse xml 命名空间
xmlns="https://www.sisow.nl/Sisow/REST"
时,它可以工作!命名空间 url 是404。那么,如果它是 404,为什么不xdoc
忽略名称空间呢?
这也不起作用:var banks = doc.Elements().Where(e => e.Name.LocalName == "issuer" ).Select(...
主要问题是:如何修改我的代码以使其忽略 404 命名空间?