<?xml version="1.0" encoding="utf-8" ?>
<Response success="true">
<data>
<class name="getId" classValue=" this is a class value"></class>
</data>
</Response>
string strPath = @"C:\Users\Fale\Documents\practice\xpathNavigator\xpathNavigator\1.xml";
XDocument Xdco = XDocument.Load(strPath);
var list = from i in Xdco.Root.Descendants("Response")
where i.Attribute("success").Value == "true"
select i.Element("data").Element("class").Attribute("classValue").Value;
How to check response is true and then to get attribute value using linq c#?
var list = from i in Xdco.Descendants("Response")
where i.Attribute("success").Value == "true"
select i.Element("data").Element("class").Attribute("classValue").Value;
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.