Replacing or removing characters in XmlDocument



//Replace or remove characters from the XmlDocument
private void ReplaceCharsInXml(XmlDocument xmlDoc, string toReplace, string replaceWith){
    String xmlString = GetXmlString(xmlDoc);
    xmlString = xmlString.Replace(toReplace, replaceWith);
    xmlDoc.LoadXml(xmlString);
}

private string GetXmlString(XmlDocument xmlDoc){
    StringWriter sw = new StringWriter();
    XmlTextWriter xw = new XmlTextWriter(sw);
    xmlDoc.WriteTo(xw);
    return sw.ToString();
}


You can view this article online at:
http://www.kiranreddys.com/knowledgebase/index.php/article/replacing-or-removing-characters-in-xmldocument