Reputation: 5600
I have a treeview which is bound to XmlDataSource. I want to search on this XmlDataSource's body for a keyword and rebind the treeview. Found this article that describes it, but my search does not return anything.
My xml looks like below:
<?xml version="1.0" encoding="utf-8"?>
<articles name="articles">
<folder name="Folder1">
<article name="art1">
<body>This is body 1</body>
<createuser>someuser</createuser>
<createddate>28/02/2013 06:24:34</createddate>
</article>
<article name="art2">
<body><p> this is body 2</body>
<createuser>someuser2</createuser>
<createddate>28/02/2013 06:30:36</createddate>
</article>
</folder>
</articles>
and the code I have used is on Button click as below and am typing "this" as 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 this too
tvCMSArts.DataBind();
}
Upvotes: 0
Views: 396
Reputation: 8736
Try this:
XmlArticle.XPath = "/articles/folder/article[contains(body,'" + txbSearch.Text + "')]";
Upvotes: 1