c# - Remove Insignificant Whitespace From Xml Document -
i've got xml file contains both significant , insignificant whitespace. read file in , write file out disk, removing insignificant whitespace. when considering significant vs insignificant whitespace, want make sure spaces within mixed content elements (as defined schema) maintained. how can using c#? based on this article read, sounded might need use validating xml reader reader know elements contain mixed content per schema. below 1 example of code tried did not maintain significant whitespace between elements within parent element containing mixed content. xmldocument doc = new xmldocument(); doc.preservewhitespace = true; using (xmltextreader rdr = new xmltextreader(xmlfilepath1)) { rdr.whitespacehandling = whitespacehandling.significant; xmlschemaset sc = new xmlschemaset(); sc.add(null, @"c:\my-schema.xsd"); doc.load(xmlreader.create(rdr, new xmlreadersettings() { validationtype = system.xml.validationtype.schema, schemas = sc })); using...