在C#中的一个文本文件中读取或查找两个xml文件路径 [英] Two xml file path read or find in a one text file in C#

查看:130
本文介绍了在C#中的一个文本文件中读取或查找两个xml文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想要两个xml文件路径[.... \ abc.xm l和... .\ xyz.xml ]从一个文本文件[ filepath.txt
]中读取并比较两个xml文件的数据,两个文件数据值不匹配比这个结果显示在一个文本文件的excel文件中。

I want to two xml file path [....\abc.xml and ....\xyz.xml ] read from in a one text file [ filepath.txt ] and compare data of both xml file , both file data value mismatch than this result show in excel file file from a one text file.

filepath.txt 包含两个.xml文件路径如:
filepath.txt  contain two .xml file path Like:

推荐答案

您好,

这是您的问题的错误论坛,因为它与WPF无关。

This is the wrong forum for your question because it's got nothing to do with WPF.

如果你想阅读txt文件,你可以参考以下文章。

If you want read the txt file ,you can refer the following article.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-read-from-a-text-file

所以你可以这样做:

 string[] lines = System.IO.File.ReadAllLines(@"filepath.txt");


如果要读取和解析xml文件,可以在System.Xml命名空间中使用XmlDocument类。

https:// msdn .microsoft.com / EN-US /库/ system.xml.xmldocument%28V = v s.110%29.aspx?f = 255& MSPPError = -2147217396

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(lines[0]);


您还可以使用System.Xml.Linq命名空间中的XDocument类。

https://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument(v = vs.110).aspx

XDocument xDocument = XDocument.Load(lines[1]);

此致,

Bob

Bob


这篇关于在C#中的一个文本文件中读取或查找两个xml文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆