I am trying to search for a term within my description element of my xml file using xpath:
XML File sample:
ASP.NET code:
I want to list all page names (Name element) where the description element includes the word 'home'. I have tried to use wild cards
which doesn't seem to work.
any idea how I can achieve this?
Thanks
XML File sample:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<Site>
<Page>
<Name>Home</Name>
<Description>
the word home maybe in the middle of a sentance.
</Description>
</Page>
</Site>
Code:
XPathDocument doc = new XPathDocument(MapPath("xmlfile.xml"));
XPathNavigator navdoc = doc.CreateNavigator();
XPathNodeIterator iter = navdoc.Select("//Page[Description='home']/Name");
// Iterate through the results.
while (iter.MoveNext())
{
XPathNavigator navCurrent = iter.Current;
ListBox1.Items.Add(navCurrent.ToString());
}
Code:
*'home'*
any idea how I can achieve this?
Thanks
Comment