【发布时间】:2014-08-21 15:35:25
【问题描述】:
我是 LinQ to XML 的新手,我在使用 Xdocument(在这种情况下)从 XML 文件中提取特定值并开始至少将其返回到控制台时遇到了麻烦。
在 XLM 中,我只需要显示某些值; 4GB493594008000-JENEXP18082014A、A1、20(在statisticalValue元素中)等
任何指针将不胜感激 - 谢谢。
有问题的 XML 是
<?xml version="1.0" encoding="utf-8"?>
<declarationGbResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="demo.com/test/DeclarationGbResponse">
<declarationIdentity>
<declarationUcr xmlns="demo.org.uk/DeclarationGbIdentityType">4GB493594008000-JENEXP18082014A</declarationUcr>
</declarationIdentity>
<responseType>ACC</responseType>
<responseTime>2014-08-18T13:36:32.79</responseTime>
<isFirstAcceptanceResponse>true</isFirstAcceptanceResponse>
<externalReferences/>
<!-- element -->
<acceptanceResponse>
<!-- element -->
<ICS xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">A1</ICS>
<entryRoute xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">H</entryRoute>
<statusOfExportEntry xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">1</statusOfExportEntry>
<entryTime xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">2014-08-18T13:36:00</entryTime>
<entryEpuNumber xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">120</entryEpuNumber>
<entryNumber xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">A05605F</entryNumber>
<entryVersionNumber xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">1</entryVersionNumber>
<movementReferenceNumber xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">14GB08X33073603018</movementReferenceNumber>
<declarationExchangeRate xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">1</declarationExchangeRate>
<declarationCurrency xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">
<currencyCode xmlns="demo.org.uk/test/Currency">GBP</currencyCode>
</declarationCurrency>
<customsValueForDuty xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">
<value xmlns="demo.org.uk/test/MonetaryType">20</value>
</customsValueForDuty>
<customsDutyPayable xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">
<value xmlns="demo.org.uk/test/MonetaryType">0</value>
</customsDutyPayable>
<deferedRevenue xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">
<value xmlns="demo.org.uk/test/MonetaryType">0</value>
</deferedRevenue>
<immediateRevenue xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">
<value xmlns="demo.org.uk/test/MonetaryType">0</value>
</immediateRevenue>
<revenuePayable xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">
<value xmlns="demo.org.uk/test/MonetaryType">0</value>
</revenuePayable>
<itemResponses xmlns="demo.org.uk/test/DeclarationGbAcceptanceResponse">
<itemResponse>
<itemNumber xmlns="demo.org.uk/test/DeclarationGbItemResponse">1</itemNumber>
<statisticalValue xmlns="demo.org.uk/test/DeclarationGbItemResponse">
<value xmlns="demo.org.uk/test/MonetaryType">20</value>
</statisticalValue>
</itemResponse>
</itemResponses>
</acceptanceResponse>
</declarationGbResponse
【问题讨论】:
标签: c# linq-to-xml