Patryk
Patryk

Reputation: 24120

Why do I get "Illegal characters in path" while using XmlDiff to compare 2 xml files?

I have a problem trying to compare 2 xml files with the XmlDiff library from Microsoft.

I am using an overloaded function which passes 2 xmls as strings :

xmldiff = new XmlDiff(XmlDiffOptions.IgnoreChildOrder | XmlDiffOptions.IgnorePrefixes | XmlDiffOptions.IgnoreNamespaces);
bool identical = xmldiff.Compare(first, last, false);

where first and last look more or less like this :

<?xml version="1.0" encoding="ISO-8859-1"?>
<breakfast_menu>
    <food>
        <name>Belgian Waffles</name>
        <price>$5.95</price>
        <description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
        <calories>650</calories>
    </food>
    <food>
        <name>Strawberry Belgian Waffles</name>
        <price>$7.95</price>
        <description>light Belgian waffles covered with strawberries and whipped cream</description>
        <calories>900</calories>
    </food>
</breakfast_menu>

And I get this error

enter image description here

EDIT:

OK, I think that was my issue - I passed whole content of the file instead of just its path or URL(as in the documentation). So now I have another problem - how can I use this overload - public Boolean Compare(XmlReader, XmlReader) or this public Boolean Compare(XmlNode, XmlNode) when I have the file contents in a string ?

Upvotes: 1

Views: 819

Answers (2)

C.J.
C.J.

Reputation: 16101

What type is first and last? Are they file paths? Or strings? I notice the encoding on your XML string is using a code page: encoding="ISO-8859-1" Is the other XML 'thing' using the same encoding?

If 'first' and 'last' are file paths: Perhaps it's your path of the files you are passing to the files? I encountered that once when parsing some files. I had an extra space in the filename. It didn't help I was programming in an IDE with small font, and I need new glasses and I was sitting 3 feet away from the monitor. That made it a bugger to see the tiny tiny space in the filename.

Upvotes: 0

Daniel A. White
Daniel A. White

Reputation: 190976

It looks like you want to pass the file path to Compare, not the xml string.

Upvotes: 1

Related Questions