2013-03-26 3 views
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을 기반으로 쿼리를 만들고 싶어 : 여기

는 코드입니다. 난 그냥 내 검색어 문자열 텍스트 상자에 혼란을 입력하면

그래서 텍스트 필드는 I가 위치한 해당 요소와 노드에 여전히 원하는, 혼란, 메스꺼움, 두통

포함되어있을 수 있습니다.

당신이 원하는 모든처럼 당신이

답변

1

그래서 소리 감사합니다

where item.Element(ns + text).Value.Contains(queryString.Text) 

겠습니까 당신을 위해 그 일?

+0

네, 제가 원한 건 ... 4 시간 전에 물어 봤어야합니다. 고맙습니다!!! – user2212561