在 C# 中从 XML 中获取某个元素

Getting a certain element from XML in C#

我要解析以下 XML 文件:

<result>
<iban>GB20ULSB98006054100029</iban>
<account>54100029</account>
<sort_code>980060</sort_code>
<bank>ULSTER BANK LTD</bank>
<branch>BELFAST CITY OFFICE 1</branch>
<bic>ULSBGB2BXXX</bic>
<address>PO BOX 232 11-16 DONEGALL SQUARE EAST </address>
<city>BT1 5UB</city>
<country>GB<country/>
<phone>028 90244112</phone>
</result>

谁能告诉我如何获取元素'iban'?

使用XDocument,可以读取元素

var xdoc = XDocument.Load("XMLFile1.xml");
var iban = xdoc.Element("result").Element("iban").Value;