tags:

views:

76

answers:

3

Hi,

I've an xml file of size 83,383 KB on a windows server.I load this file using MS xml parser and it works fine.

When I copy this file to another windows server, the size of file becomes 83,392 KB.When i load this file using MS xml parser, I get xml parser error message: "Data at the root level is invalid. Line 1116371, position 8."

What am i missing over here?

Thanks for reading!

+2  A: 

When I copy this file to another windows server, the size of file becomes 83,392 KB.

Maybe you should check and see what the deal is here? Copying a file isn't supposed to change it.

Run the files through windiff, fc, whatever.

Michael Burr
A: 

Two options I can think of:

  1. You're using different versions of the XML parser, and one is stricter than the other
  2. Your file copy isn't accurate

How are you copying the files? If you take the MD5 checksum of the two files, are they the same?

The next obvious thing to do is see what's in line 1116371. Here's a short C# program which will show you a specified line for a big file (it assumes UTF-8 encoding, but you could change that):

using System;
using System.IO;

public class ShowLine
{
    static void Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("Usage: ShowLine <file> <line>");
            return;
        }
        // TODO: error checking for argument validity
        string file = args[0];
        int lineNo = int.Parse(args[1]);
        using (TextReader reader = File.OpenText(file))
        {
            string line = null;
            for (int i=0; i < lineNo; i++)
            {
                line = reader.ReadLine();
                if (line == null)
                {
                    Console.WriteLine("Not enough lines in file!");
                    return;
                }
            }
            Console.WriteLine(line);
        }
    }
}
Jon Skeet
A: 

Hi, I copied xml file using windows copy command.

Please edit your question or add a comment. Answers are for answers on your question ;-).
Gamecat