<response>
<payment loanType="thirtyYearFixed">
<rate>4.09</rate>
<monthlyPrincipalAndInterest>410</monthlyPrincipalAndInterest>
<monthlyMortgageInsurance>54</monthlyMortgageInsurance>
</payment>
</response>
私の質問は、レート、monthlyPrincipalAndInterest、およびmonthlyMortgageInsurance から情報を取得するにはどうすればよいですか? 私はあらゆる方法を試しましたが、これを投稿する前の最後の手段として次のコードを使用して XDocument で停止しました。
Rate = root.SelectSingleNode("//response/payment[@loanType='thirtyYearFixed']/rate").InnerText;
これは rate 子要素のコードです。解析中の XML ファイルのこの部分の前にすべての情報を取得しましたが、これでレンガの壁にぶつかり、理解できないようです。//response/payment[@loanType='thirtyYearFixed'] 変数として XMLNodeList を使用し、次に nodeVar["rate"].InnerText を使用しても、null 参照エラーが発生しました。
これは私が見過ごした小さな断片になると感じていますが、オプションが不足しているだけでなく、時間が不足しています。