XML clone/possible encoding/byte order mark problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Donal McWeeney

    XML clone/possible encoding/byte order mark problem

    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.Pre serveWhitespace = true ;
    inputXmlDoc.Loa d( inputFileFullNa me ) ;

    // clone the input document
    XmlDocument outputXmlDoc = (XmlDocument) inputXmlDoc.Clo neNode( true ) ;
    outputXmlDoc.Pr eserveWhitespac e = true ;

    // save the manifest file
    outputXmlDoc.Sa ve( manifestFullNam e ) ;

    Could the problem just be with WinDiff?

    Thanks

    Donal


  • Jon Skeet [C# MVP]

    #2
    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.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Donal McWeeney

      #3
      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.co m> wrote in message
      news:MPG.1a3153 cd45a19572989b6 5@msnews.micros oft.com...[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.co m>
      > http://www.pobox.com/~skeet
      > If replying to the group, please do not mail me too[/color]


      Comment

      Working...