XML连接要设置为XAttribute的字符串
我正在读取一个CSV文件以转换为XML格式。如何在其中一个字段之前连接固定字符串 在本例中,我需要将domain\附加到用户名XML连接要设置为XAttribute的字符串,xml,string,csv,concatenation,xattribute,Xml,String,Csv,Concatenation,Xattribute,我正在读取一个CSV文件以转换为XML格式。如何在其中一个字段之前连接固定字符串 在本例中,我需要将domain\附加到用户名 string[] csvString = File.ReadAllLines("file.csv"); XElement xmlString = new XElement("XML", new XElement("IDENTITIES", from str in
string[] csvString = File.ReadAllLines("file.csv");
XElement xmlString =
new XElement("XML",
new XElement("IDENTITIES",
from str in csvString
let fields = str.Split(',')
select new XElement("IDENTITY",
new XAttribute("ID", fields[1]),
new XAttribute("SERVICE", "SERV"),
new XAttribute("DOMAIN_USER", fields[2]),
new XAttribute("PASSWORD","PASSWORD")
如何将域\用户X属性设置为连接的域\字段[2]?为什么不简单地连接字符串
new XAttribute("DOMAIN_USER", "DOMAIN\\" + fields[2]),
这实际上是我尝试的第一件事,只是,我使用了一个\并不断得到一个换行符,所以我认为我没有正确连接字符串。考虑到这是我第一次尝试C应用程序,我不知道您需要使用\\。