简体   繁体   中英

Get value from a XML

I have a XML .How to get CustomerSet value from this ?

<a:CreditCards>
 <a:CreditCard>
  <a:AccountNumber>1234XXXXXX23XXXX</a:AccountNumber> 
 <a:ExtendedInfo>
  <a:CustomerSet>RC808687</a:CustomerSet> 
 </a:ExtendedInfo>
 </a:CreditCard>
<a:CreditCards>

尝试使用XPath,要获取CustomerSet值,xpath将为/CreditCards/CreditCard/ExtendedInfo/CustomerSet

Have a look at this

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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM