我從包含幾個命名空間的XML文件導入一些數據。我使用嵌套類來導入不同級別的數據。不幸的是我無法訪問內部類中的數據。我知道問題是關於命名空間的,但我不知道如何在不修改內部類的情況下解決它們。有誰知道我如何解析XDocument中的命名空間。在XDocument中解析命名空間c#
這是XML的一部分:
<TransXChange xmlns="http://www.transxchange.org.uk/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:apd="http://www.govtalk.gov.uk/people/AddressAndPersonalDetails"
xsi:schemaLocation="http://www.transxchange.org.uk/ http://www.transxchange.org.uk/schema/2.1/TransXChange_registration.xsd"
xml:lang="en" CreationDateTime="2004-06-09T14:20:00-05:00"
>
<Operators>
<LicensedOperator id="O1" >
<NationalOperatorCode>ABC</NationalOperatorCode>
<OperatorAddresses>
<CorrespondenceAddress>
<apd:Line>45 City Road</apd:Line>
</CorrespondenceAddress>
</OperatorAddresses>
</LicensedOperator>
</Operators>
</TransXChange>
在這裏簡單的搜索SO應該告訴你解決方案 – BrokenGlass