XML : how to fetch node elements from XML file by using xpath query,

i want to fetch elements through search pattern like if i type "an" then i want all elements which have "an" example =man, animal, fan, pant

this is my code here i use foreach loop to display all search elements but i don't want to use foreach loop just i want to fetch all the list directly form xpath query please help me out its very impotent for me

private void Search2_Click_1(object sender, EventArgs e) {

          XmlNodeList nodes = myxml.DocumentElement.SelectNodes("/students/student/s_name" );            string ha = search.Text;            if (listbox11.Text == "Name")          foreach(XmlNode node in nodes)          {                if(System.Text.RegularExpressions.Regex.IsMatch(node.InnerText,ha))              {                   listBox1.Text += node.InnerText + "\r\n";               }            }        }    

No comments:

Post a Comment