Connecting Tech Pros Worldwide Help | Site Map

XML clone/possible encoding/byte order mark problem

Donal McWeeney
Guest
 
Posts: n/a
#1: Nov 15 '05
Hi,

I think I may have a slight encoding problem with what I am doing.

I have a test console app that takes an xml document and splits it
into a number of smaller xml documents.

First thing I do is clone the input document. At the moment I am just
saving this document and when I do a windiff on the documents I see some
surouis characters at the beginning of the document I saved.

I guess these are the byte order marks - however if I edit this doc in
VS.Net or notepad these chars are not visible.

Code thus far is very simple:

// load the schema input file
XmlDocument inputXmlDoc = new XmlDocument() ;
inputXmlDoc.PreserveWhitespace = true ;
inputXmlDoc.Load( inputFileFullName ) ;

// clone the input document
XmlDocument outputXmlDoc = (XmlDocument) inputXmlDoc.CloneNode( true ) ;
outputXmlDoc.PreserveWhitespace = true ;

// save the manifest file
outputXmlDoc.Save( manifestFullName ) ;

Could the problem just be with WinDiff?

Thanks

Donal


Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#2: Nov 15 '05

re: XML clone/possible encoding/byte order mark problem


Donal McWeeney <donal_mcweeney@NO-SP-AM.aimware.com> wrote:[color=blue]
> I think I may have a slight encoding problem with what I am doing.
>
> I have a test console app that takes an xml document and splits it
> into a number of smaller xml documents.
>
> First thing I do is clone the input document. At the moment I am just
> saving this document and when I do a windiff on the documents I see some
> surouis characters at the beginning of the document I saved.
>
> I guess these are the byte order marks - however if I edit this doc in
> VS.Net or notepad these chars are not visible.[/color]

<snip>
[color=blue]
> Could the problem just be with WinDiff?[/color]

The only problem is that you've got two documents which are
semantically the same but which aren't represented in the same way.
Assuming the first two bytes are FF FE or FE FF, you're right - they're
byte order marks, and nothing to worry about.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Donal McWeeney
Guest
 
Posts: n/a
#3: Nov 15 '05

re: XML clone/possible encoding/byte order mark problem


Hi Jon,

Thanks for the very quick reply...

Thanks

Donal

"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1a3153cd45a19572989b65@msnews.microsoft.c om...[color=blue]
> Donal McWeeney <donal_mcweeney@NO-SP-AM.aimware.com> wrote:[color=green]
> > I think I may have a slight encoding problem with what I am doing.
> >
> > I have a test console app that takes an xml document and splits it
> > into a number of smaller xml documents.
> >
> > First thing I do is clone the input document. At the moment I am just
> > saving this document and when I do a windiff on the documents I see some
> > surouis characters at the beginning of the document I saved.
> >
> > I guess these are the byte order marks - however if I edit this doc in
> > VS.Net or notepad these chars are not visible.[/color]
>
> <snip>
>[color=green]
> > Could the problem just be with WinDiff?[/color]
>
> The only problem is that you've got two documents which are
> semantically the same but which aren't represented in the same way.
> Assuming the first two bytes are FF FE or FE FF, you're right - they're
> byte order marks, and nothing to worry about.
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too[/color]


Closed Thread


Similar C# / C Sharp bytes