I create a xml document and try to get the string out of it like this:
string path = "c:\temp\window.xaml";
FileStream stream = new FileStream(@path, FileMode.Open);
XmlDocument doc = new XmlDocument();
doc.Load(stream);
string insideString = doc.FirstChild.OuterXml;
Here is the content of a window.xaml file:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Name="Window"
Title="MainWindow"
Width="1024" Height="768">
<Grid/>
</Window>
However, the content of a string insideString from the code above does not match this xaml file. It looks like this:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Ignorable="d"
x:Name="Window"
Title="MainWindow"
Width="1024" Height="768">
<Grid/>
</Window>
The difference is in the mc:Ignorable
and Ignorable
. The mc: prefix is missing in the output.
Is there a way, how to prevent the Xml Document from deleting this prefix?
Thanks for any answer