You must Sign In to post a response.
  • Category: ASP.NET

    XML Document not replacing value

    Hi All,

    XMLDOCUMENT replace is not working for me. While debug If I press Shift+F9 it was replaced value but not working in direct debug.
    I have many %26amp; in my innerXML values, that's y I wanted to replace all together.

    XmlDocument soapXml = new XmlDocument();
    soapXml.LoadXml(inputxml);
    soapXml.InnerXml.Replace("%26amp;", "&"); // Replace not happening.

    Could please let me know what was happened there.
  • #763518
    can u try the following

    .replace(/&/g,'&')

    By Nathan
    Direction is important than speed

  • #763521
    XML does not support unicodes directly, you can not convert '&' to '& ' as it is the Unicode of '&', like wise
    '<' is converted to '<' and '>' is converted to ''>'
    so the final answer is, you can not.

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #763526
    Hello Rajan,

    Use the below function to replace the value instead of some special values for XML :

    VB.NET :

    Private Function ReplaceXmlText(ByVal strXmlText As String) As String
    Dim strXml As String
    strXml = Replace(strXmlText, "&", "&")
    strXml = Replace(strXml, "'", "'")
    strXml = Replace(strXml, """", """)
    strXml = Replace(strXml, ">", ">")
    strXml = Replace(strXml, "<", "<")
    ReplaceXmlText = strXml
    End Function

    How to Use :
    Dim myval As String = ReplaceXmlText("&")

    C# :

    private string ReplaceXmlText(string strXmlText)
    {
    string strXml = null;
    strXml = Strings.Replace(strXmlText, "&", "&");
    strXml = Strings.Replace(strXml, "'", "'");
    strXml = Strings.Replace(strXml, "\"", """);
    strXml = Strings.Replace(strXml, ">", ">");
    strXml = Strings.Replace(strXml, "<", "<");
    return strXml;
    }

    How to Use :
    string myval = ReplaceXmlText("&");

    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"


Sign In to post your comments