我有一个XML。如何从中获取CustomerSet值?
<a:CreditCards>
<a:CreditCard>
<a:AccountNumber>1234XXXXXX23XXXX</a:AccountNumber>
<a:ExtendedInfo>
<a:CustomerSet>RC808687</a:CustomerSet>
</a:ExtendedInfo>
</a:CreditCard>
<a:CreditCards>
答案 0 :(得分:0)
尝试使用XPath,
要获取CustomerSet值,xpath将为/CreditCards/CreditCard/ExtendedInfo/CustomerSet
答案 1 :(得分:0)
看看这个
XmlDocument xml = new XmlDocument();
xml.LoadXml("<CreditCards> <CreditCard> <AccountNumber>1234XXXXXX23XXXX</AccountNumber> <ExtendedInfo> <CustomerSet>RC808687</CustomerSet> </ExtendedInfo> </CreditCard> </CreditCards> ");
XmlNodeList xmlList = xml.SelectNodes("/CreditCards/CreditCard/ExtendedInfo/CustomerSet");