c# - search xml using xpath - Treeview -
i have treeview bound xmldatasource. want search on xmldatasource's body keyword , rebind treeview. found article describes it, search not return anything.
my xml looks below:
<?xml version="1.0" encoding="utf-8"?> <articles name="articles"> <folder name="folder1"> <article name="art1"> <body>this body 1</body> <createuser>someuser</createuser> <createddate>28/02/2013 06:24:34</createddate> </article> <article name="art2"> <body><p> body 2</body> <createuser>someuser2</createuser> <createddate>28/02/2013 06:30:36</createddate> </article> </folder> </articles>
and code have used on button click below , typing "this" keyword:
protected void btnsearch_click(object sender, eventargs e) { xmlarticle.xpath = "/articles/folder/article[body='" + txbsearch.text + "']"; //xmlarticle.xpath = "/articles/folder[article/body='" + txbsearch.text + "']"; //tried tvcmsarts.databind(); }
try this:
xmlarticle.xpath = "/articles/folder/article[contains(body,'" + txbsearch.text + "')]";
Comments
Post a Comment