我有一个像这样的XML文件,
<SellingCode>
<LastUpdated>2016-01-05T08:36:53+00:00</LastUpdated>
<SellingCodeID>5045460018689</SellingCodeID>
<SellingCodeID>103018090008</SellingCodeID>
<ProductID>1030180900</ProductID>
</SellingCode>
如何生成这样的数据
2016-01-05T08:36:53+00:00 | 5045460018689 | 1030180900
2016-01-05T08:36:53+00:00 | 103018090008 | 1030180900
你们有没有想过我在c#中怎么做?
答案 0 :(得分:0)
反序列化到下面的类,然后迭代/ lync以获得您所追求的格式。
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public class SellingCode
{
private System.DateTime lastUpdatedField;
private ulong[] sellingCodeIDField;
private uint productIDField;
/// <remarks/>
public System.DateTime LastUpdated
{
get
{
return this.lastUpdatedField;
}
set
{
this.lastUpdatedField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("SellingCodeID")]
public ulong[] SellingCodeID
{
get
{
return this.sellingCodeIDField;
}
set
{
this.sellingCodeIDField = value;
}
}
/// <remarks/>
public uint ProductID
{
get
{
return this.productIDField;
}
set
{
this.productIDField = value;
}
}
}
答案 1 :(得分:-1)
LINQ to XML将为您效劳。
var document = XDocument.Load("file.xml");
var array = document.Descendants("COL").Select(x => (int) x).ToArray();