我正在使用以下 linq to xml 查询在 XML 文件中搜索元素
XElement inspections = XElement.Load(new StreamReader( Server.MapPath(ResolveUrl(SelectInspection.InspectionFilePath)),Encoding.UTF8));
XElement inspection = (from elements in inspections.Elements("inspection")
where elements.Element("inspectionid").Value == inspectionId.ToString()
&& elements.Element("databasename").Value == Encoding.UTF8.GetString(Request.ContentEncoding.GetBytes (Request.QueryString("DbName")))
select elements).Single();
我的 xml 文件是
<?xml version="1.0" encoding="utf-8"?>
<inspections>
<inspection>
<inspectionid>8</inspectionid>
<databasename>Åker</databasename>
<exported>false</exported>
</inspection>
</inspections>
尽管Request.QueryString("DbName")
等于 "Åker",但查询不返回任何结果。