When using an XPath binding expression, can you return InnerXml rather than InnerText?

I bind the control to an XmlDocument and use the XPath binding expression to output the data:

<div class="Bio"><%# XPath("Biography") %></div>

However, this returns the InnerText property of the Biography element, not InnerXml. This means that it removes all internal tags from it, which I don't want.

I looked at the XPathBinder object, but I cannot find it to return InnerXml, not InnerText

+3
source share
1 answer

Binding.XPath , node, InnerXml . , SelectSingleNode (...). InnerXml? ,

public string GetInnerXml(object o)
{
    string val = String.Empty;
    XmlNode parent = o as XmlNode;
    XmlNode child = parent.SelectSingleNode("bob/fred");
    if (child != null)
        val = child.InnerXml;
    return val;
}

, . , , .

0

Source: https://habr.com/ru/post/1703701/


All Articles