<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>read write InfoPath with XmlDocument</title><link>https://www.infopathdev.com:443/forums/thread/29134.aspx</link><pubDate>Tue, 03 Jun 2008 18:28:32 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:29134</guid><dc:creator>AntonM</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/29134.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=29134</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hi All,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I try to read and save an InfoPath document which is signed with a digital signature.&lt;/p&gt;
&lt;p&gt;We use InfoPath 2003 SP3.&lt;/p&gt;
&lt;p&gt;Here some code I tried:&lt;/p&gt;
&lt;p&gt;1.&lt;/p&gt;
&lt;p&gt;string xmlContent = File.ReadAllText(&amp;quot;sample.xml&amp;quot;); &lt;/p&gt;
&lt;p&gt;File.WriteAllText(&amp;quot;sample_2.xml&amp;quot;, );&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Works fine!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2.&lt;/p&gt;
&lt;p&gt;XmlDocument xdoc = new XmlDocument();&lt;/p&gt;
&lt;p&gt;string xmlContent = File.ReadAllText(&amp;quot;sample.xml&amp;quot;); xdoc.LoadXml(xmlContent);&lt;/p&gt;
&lt;p&gt;File.WriteAllText(&amp;quot;sample_2.xml&amp;quot;, xdoc.OuterXml);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When I open the sample_2.xml I get an error that sounds like that (translated from German):&lt;/p&gt;
&lt;p&gt;All or one signature could not be verified...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried some other Writer classes like StringWriter, XmlTextWriter or StreamWriter, but I get always the same error.&lt;/p&gt;
&lt;p&gt;I think it is an encoding issue. So if I compare these two files with winDiff, there are many differences.&lt;/p&gt;
&lt;p&gt;Could someone tell me please how to write a valid InfoPath xml document without have impact on the existing signatures. Which Encoding uses the OuterXML property?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks a lot,&lt;/p&gt;
&lt;p&gt;Anton&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>