1. XDocument doc = XDocument.Parse(returnValue.Trim());
var cdistinct = doc.Descendants("reportname").Where(p => Convert.ToString(p.Element(x).Value).Trim() != "").Select(p => Convert.ToString(p.Element(x).Value)).Distinct();
string[] dataDistinct=new string[cdistinct.Count()];
int i=0;
foreach (var count1 in cdistinct)
{
dataDistinct.SetValue(count1, i);
i++;
}
return dataDistinct;
2. XElement xml = XElement.Load(文件地址名称); //定义查询方法
var query = from c in xml.DescendantsAndSelf("Customers")
select new CustomerInfo
{
CustomerID = c.Elements("CustomerID").SingleOrDefault().Value,
CompanyName = c.Elements("CompanyName").SingleOrDefault().Value,
ContactName = c.Elements("ContactName").SingleOrDefault().Value,
ContactTitle = c.Elements("ContactTitle").SingleOrDefault().Value,
Address = c.Elements("Address").SingleOrDefault().Value,
City = c.Elements("City").SingleOrDefault().Value,
PostalCode = c.Elements("PostalCode").SingleOrDefault().Value,
Country = c.Elements("Country").SingleOrDefault().Value,
Phone = c.Elements("Phone").SingleOrDefault().Value,
Fax = c.Elements("Fax").SingleOrDefault().Value,
Region = c.Elements("Region").SingleOrDefault().Value != "" ? true : false
};