c# - Parsing Xml via XPath gives error -


i have simple xml string loaded using xmldocument class. trying read via xpath query , error,

"expression must evaluate node-set."

here xml,

<rf_searchtermbanners>    <imagename>3pc-leather-set.jpg</imagename> </rf_searchtermbanners> 

here c# code,

protected void bindsearchbanner(string imageurl) {     //parse xml string containing image name     system.xml.xmldocument xmldoc = new system.xml.xmldocument();     xmldoc.loadxml(imageurl);      system.xml.xmlnode node = (system.xml.xmlnode)xmldoc.documentelement;     system.xml.xmlelement imageelem = node.selectsinglenode("@/rf_searchtermbanners/imagename") system.xml.xmlelement;      string imgurl = imageelem.innertext;      if (imgurl != null && imgurl != string.empty)     {         searchbanner.imageurl = "~/themes/default/images" + imgurl;         searchbanner.visible = true;     }     else     {         searchbanner.imageurl = string.empty;         searchbanner.visible = false;     } } 

please help.

did mean @"/rf_searchtermbanners/imagename"? in xpath, @ symbol represents attribute.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -