У меня есть очень простая строка XML, которую я загрузил с помощью класса XmlDocument.Теперь я пытаюсь прочитать его с помощью запроса XPath, и я получаю эту ошибку,
"Выражение должно оцениваться как набор узлов."
Вот мой Xml,
<RF_SearchTermBanners>
<ImageName>3pc-leather-set.jpg</ImageName>
</RF_SearchTermBanners>
Вот мой код C #,
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") as 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;
}
}
Пожалуйста, помогите.