次の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>
is equal to "Åker"にもかかわらずRequest.QueryString("DbName")
、クエリは結果を返しません。