0

XmlNodeList我从 xml 文档中得到一个列表。我可以使用GetElementsByTagName. 但我需要从内部标签读取值。只想在“Currency CrossOrder="0" Kod="USD" CurrencyCode="USD"" 部分中阅读“USD”。

<Currency CrossOrder="0" 
          Kod="USD" 
          CurrencyCode="USD">
    <Unit>1</Unit>
    <Isim>ABD DOLARI</Isim>
    <CurrencyName>US DOLLAR</CurrencyName>
    <ForexBuying>4.0707</ForexBuying>
    <ForexSelling>4.0780</ForexSelling>
    <BanknoteBuying>4.0678</BanknoteBuying>
    <BanknoteSelling>4.0841</BanknoteSelling>
    <CrossRateUSD />
    <CrossRateOther />
</Currency>
<Currency CrossOrder="1" 
          Kod="AUD" 
          CurrencyCode="AUD">
    <Unit>1</Unit>
    <Isim>AVUSTRALYA DOLARI</Isim>
    <CurrencyName>AUSTRALIAN DOLLAR</CurrencyName>
    <ForexBuying>3.1389</ForexBuying>
    <ForexSelling>3.1594</ForexSelling>
    <BanknoteBuying>3.1245</BanknoteBuying>
    <BanknoteSelling>3.1784</BanknoteSelling>
    <CrossRateUSD>1.2938</CrossRateUSD>
    <CrossRateOther />
</Currency>
4

1 回答 1

1

对于XmlReader,<Currency CrossOrder="0" Kod="USD" CurrencyCode="USD">是一个Element类型的节点。

CurrencyCode是该节点中的一个属性。如果您想获得“USD”,您将获得CurrencyCode属性的值。

试试XmlReader.GetAttribute方法。

请参阅Microsoft 文档

于 2018-04-10T14:10:04.327 回答