using System; using System.Text.RegularExpressions;
public static class XMLUtility { public static string RemoveWhitespace( string xml ) { Regex regex = new Regex(@">\s*<"); xml = regex.Replace(xml, "><");
Hi : How can i use your code for my case ? private void saveDocument(XmlDocument doc, string filename) { StreamWriter wr = new StreamWriter(filename); wr.Write(doc.OuterXml); wr.Close(); wr.Dispose(); }
I get white space in my xml output after i compile my project???
3 comments:
Hi :
How can i use your code for my case ?
private void saveDocument(XmlDocument doc, string filename)
{
StreamWriter wr = new StreamWriter(filename);
wr.Write(doc.OuterXml);
wr.Close();
wr.Dispose(); }
I get white space in my xml output after i compile my project???
Try removing the XML whitespace from doc.OuterXml when you write it into the StreamWriter:
wr.Write(XMLUtility.RemoveWhitespace(doc.OuterXml));
Check out CodeContrib for more examples and extra helpers.
This saved my life !!
Thanks Andrew !!!!!!!!
Post a Comment