PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework New line and Tabs in XML files?

Reply

New line and Tabs in XML files?

 
Thread Tools Rate Thread
Old 11-09-2006, 09:20 AM   #1
Ole
Guest
 
Posts: n/a
Default New line and Tabs in XML files?


Hi, I have a strange problem - when writing to a file from a Full framework
application I get the normal XML format but when I write to a file in a
Compact Framework application using the exact same code I get one single
unwrapped linin XML.?? I'm using XML serialization like this:

TestObject test = new TestObject();
XmlSerializer ser = new XmlSerializer(test.GetType());

StreamWriter file = new StreamWriter(@"C:\test.xml");
ser.Serialize(file, test);
file.Flush();
file.Close();

What can I do correct that problem?

Thanks
Ole


  Reply With Quote
Old 11-09-2006, 03:40 PM   #2
=?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=
Guest
 
Posts: n/a
Default RE: New line and Tabs in XML files?

Try this:


System.Xml.Serialization.XmlSerializer ser = new
System.Xml.Serialization.XmlSerializer(test.GetType());

System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\test.xml");
System.Xml.XmlTextWriter xtr = new System.Xml.XmlTextWriter(file);
xtr.Formatting = System.Xml.Formatting.Indented;
ser.Serialize(xtr, test);
file.Flush();
file.Close();

HTH

Ciaran O'Donnell


"Ole" wrote:

> Hi, I have a strange problem - when writing to a file from a Full framework
> application I get the normal XML format but when I write to a file in a
> Compact Framework application using the exact same code I get one single
> unwrapped linin XML.?? I'm using XML serialization like this:
>
> TestObject test = new TestObject();
> XmlSerializer ser = new XmlSerializer(test.GetType());
>
> StreamWriter file = new StreamWriter(@"C:\test.xml");
> ser.Serialize(file, test);
> file.Flush();
> file.Close();
>
> What can I do correct that problem?
>
> Thanks
> Ole
>
>
>

  Reply With Quote
Old 11-09-2006, 03:55 PM   #3
Ole
Guest
 
Posts: n/a
Default Re: New line and Tabs in XML files?

Thanks Ciaran!


"Ciaran O''Donnell" <CiaranODonnell@discussions.microsoft.com> wrote in
message news:ECFBF4E4-4ECF-4717-9740-920F69FED89A@microsoft.com...
> Try this:
>
>
> System.Xml.Serialization.XmlSerializer ser = new
> System.Xml.Serialization.XmlSerializer(test.GetType());
>
> System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\test.xml");
> System.Xml.XmlTextWriter xtr = new System.Xml.XmlTextWriter(file);
> xtr.Formatting = System.Xml.Formatting.Indented;
> ser.Serialize(xtr, test);
> file.Flush();
> file.Close();
>
> HTH
>
> Ciaran O'Donnell
>
>
> "Ole" wrote:
>
>> Hi, I have a strange problem - when writing to a file from a Full
>> framework
>> application I get the normal XML format but when I write to a file in a
>> Compact Framework application using the exact same code I get one single
>> unwrapped linin XML.?? I'm using XML serialization like this:
>>
>> TestObject test = new TestObject();
>> XmlSerializer ser = new XmlSerializer(test.GetType());
>>
>> StreamWriter file = new StreamWriter(@"C:\test.xml");
>> ser.Serialize(file, test);
>> file.Flush();
>> file.Close();
>>
>> What can I do correct that problem?
>>
>> Thanks
>> Ole
>>
>>
>>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off