I use the Code from here(Answer from Wiimax) to convert my \[code\]FlowDocument\[/code\] to \[code\]XML\[/code\] and convert it back to \[code\]FlowDocument\[/code\]. But now i have some Problems here.My Code for the convert:\[code\]public static bool IsFlowDocument(this string xamlString) { if (xamlString == null || xamlString == "") throw new ArgumentNullException(); if (xamlString.StartsWith("<") && xamlString.EndsWith(">")) { XmlDocument xml = new XmlDocument(); try { xml.LoadXml(string.Format("<Root>{0}</Root>", xamlString)); return true; } catch (XmlException) { return false; } } return false; } public static FlowDocument toFlowDocument(this string xamlString) { if (IsFlowDocument(xamlString)) { var stringReader = new StringReader(xamlString); var xmlReader = System.Xml.XmlReader.Create(stringReader); return XamlReader.Load(xmlReader) as FlowDocument; } else { Paragraph myParagraph = new Paragraph(); myParagraph.Inlines.Add(new Run(xamlString)); FlowDocument myFlowDocument = new FlowDocument(); myFlowDocument.Blocks.Add(myParagraph); return myFlowDocument; } }\[/code\]I enter this code(as example, its not the code, which i use in my program):
And after convert i get back this code:
You see that some blank were skipped. And after the namespace there was add a { }I looked at the converted XML String, there are no blank skipped, but the { } is their toDo someone know how to fix that or see a fail from me?Sorry for my english..