我有一个 xml,但我不知道该怎么写。因为这个xml里面有子列表。我不知道我该怎么写?你能帮我谈谈这一点吗?
<?xml version="1.0" encoding="ISO-8859-9"?>
<SALES_INVOICES>
<INVOICE DBOP="INS" >
<TYPE>9</TYPE>
<TRANSACTIONS>
<TRANSACTION>
<TYPE>4</TYPE>
</TRANSACTION>
<TRANSACTION>
<TYPE>4</TYPE>
</TRANSACTION>
</TRANSACTIONS>
<PAYMENT_LIST>
<PAYMENT>
<DATE>01.01.2013</DATE>
</PAYMENT>
</PAYMENT_LIST>
<AFFECT_RISK>0</AFFECT_RISK>
<DOC_DATE>19.03.2013</DOC_DATE>
<GUID></GUID>
<EDURATION_TYPE>0</EDURATION_TYPE>
<EDTCURR_GLOBAL_CODE>TL</EDTCURR_GLOBAL_CODE>
</INVOICE>
</SALES_INVOICES>
我写代码;
using (XmlWriter writer = XmlWriter.Create("C:\\1.xml"))
{
writer.WriteStartDocument();
writer.WriteStartElement("SALES_INVOICES");
writer.WriteStartElement("INVOICE");
writer.WriteAttributeString("DBOP", "INS");
writer.WriteStartElement("Trancastions");
foreach (var transaction in orderTransactionDto)
{
writer.WriteStartElement("Trancastion");
writer.WriteElementString("ID", transaction.Id.ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
}
如何将此 linq 写入 xml ?
此致。