0
我正在使用XElement來搜索用戶通過openfiledialog選擇的XML文檔。XElement中的通配符搜索
下面是代碼:
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文本框,然後我希望它仍然位於該元素和節點。
謝謝
是的,我想要的就是......我應該在4個小時前問過。謝謝!!! – user2212561 2013-03-26 17:34:11