这是我的XML代码:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/".....>
<soapenv:Header />
<soapenv:Body>
<p297:wsvitaneteResponse xmlns:p297="http://names-space.fr">
<wsvitaneteReturn>
<o_ERREUR />
<o_TARIFS>
<TARIFV1>115.49</TARIFV1>
<TARIFV1A>123.49</TARIFV1A>
<TARIFV1B>123.49</TARIFV1B>
<TARIFV1AB>131.49</TARIFV1AB>
<TARIFV2>144.05</TARIFV2>
<TARIFV2A>152.05</TARIFV2A>
<TARIFV2B>152.05</TARIFV2B>
<TARIFV2AB>160.05</TARIFV2AB>
</o_TARIFS>
</wsvitaneteReturn>
</p297:wsvitaneteResponse>
</soapenv:Body>
</soapenv:Envelope>
我可以从这个XML中获得 TARIFV1 吗?这是代码C#:
XDocument doc = XDocument.Parse(Session["xmlrs" + z + ""].ToString());
XNamespace foobar = "http://names-space.fr";
var TARIF = doc.Descendants(foobar + "TARIFV1").Select(
x => new { TARIFV1 = (string)x }).ToList();
我必须添加一些东西吗?
答案 0 :(得分:0)
为什么不使用此代码:
var TARIF = doc.Descendants("TARIFV1").Select(x => x.Value).ToList();