我正在使用 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 的查询成为通配符。
因此文本字段可能包含 Confusion、Nausea、Headache
如果我只是在我的 queryString 文本框中输入混淆,那么我仍然希望它能够定位该元素和节点。
谢谢