我有两个xml结果我需要找到它们是否正确。
代码:
[TestCase]
public void InterrogateChangeInCircumstances()
{
// Accepting the input as well as the output
string test = inputInterrogateChangeInCircumstances();
string output = outputInterrogateChangeInCircumstances();
//Web Service is getting called.
var request = (HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["request_url"]);
request.Method = "POST";
var result = Utils.ProcessRequest(request, test);
//Determing whether the response is passed or failed.
result = result.Replace(Environment.NewLine, "").Replace(" ", "");
output = output.Replace(Environment.NewLine, "").Replace(" ", "");
if (result.Equals(output))
Assert.Pass();
else
Assert.Fail("result: {0} original: {1}", result, output);
}
我不想比较result.equal(输出)。因为结果和输出都是xml文档。我想知道我是否可以比较这两个xml(结果和输出)是否相同。
答案 0 :(得分:1)
您必须为此构建自己的解析和验证机制,或者使用此答案中共享的实用程序,这与您的查询类似:Check if two XML files are the same in C#?