XElementを使用して、ユーザーがopenfiledialogから選択したXMLドキュメントを検索しています。
コードは次のとおりです。
private void dothis()
{
string query;
XElement xml = XElement.Load(path);
XNamespace ns = xml.GetDefaultNamespace();
IEnumerable<XElement> symptoms =
from item in xml.Descendants(ns + "section")
where (string) item.Element(ns + "text") == queryString.Text
select item;
// Execute the query
foreach (var complaints in symptoms)
{
// Instantiate the writer
_writer = new TextBoxStreamWriter(txtConsole);
// Redirect the out Console stream
Console.SetOut(_writer);
Console.WriteLine(complaints);
}
//Pause the application
Console.ReadLine();
}
queryString.textに基づくクエリをワイルドカードにしたい。
したがって、テキストフィールドには、混乱、吐き気、頭痛が含まれる可能性があります
queryStringテキストボックスにconfusionと入力しただけの場合でも、その要素とノードを配置する必要があります。
ありがとうございました