使用Linq查询XML到xml

时间:2013-03-25 09:28:03

标签: xml

如何使用Linq To Access检索元素客户,结果和原因的值。

 <?xml version="1.0"?>
 <!DOCTYPE CreateAccount>
  <CreateAccount>
  <Customer>tonytsund</Customer>
   <Result>Failed</Result>
   <Reason>Reseller/Password combination unknown</Reason>
   </CreateAccount>

1 个答案:

答案 0 :(得分:0)

试试这个:

XElement xe = XElement.Load(ur xml);
    var CusValue = from a in xe.Elements("Customer")
                   select a.Value;
    var ResultValue= from a in xe.Elements("Result")
                      select a.Value;
    Var ReasonValue= from a in xe.Elements("Reason")
                      select a.Value;