请查看代码并建议我如何使用C#
执行此操作我在字符串变量
中有以下节点 <state_tax_pin>d</state_tax_pin>
<loan_amount>139397.0000</loan_amount>
<note_date>2009-07-27T00:00:00+05:30</note_date>
<orig_rec_date>2015-09-02T00:00:00+05:30</orig_rec_date>
<recording_information>sdf</recording_information>
<address>address</address>
我正在尝试转换为以下格式
<state_tax_pin></state_tax_pin>
<original_terms>
<loan_amount>645000</loan_amount>
<note_date>2002-04-05</note_date>
<orig_rec_date>2002-04-16</orig_rec_date>
<recording_information></recording_information>
</original_terms>
<address>address</address>
请问我怎么能这样做
答案 0 :(得分:0)
我认为你需要一个根元素。
XElement root = new XElement("root",
new XElement("state_tax_pin", state_tax_pin),
new XElement("original_terms",
new XElement("loan_amount", loan_amount),
new XElement("note_date", note_date.ToString("yyyy-MM-dd")),
new XElement("orig_rec_date", rig_rec_date.ToString("yyyy-MM-dd")),
new XElement("recording_information", recording_information)
),
new XElement("address", address)
);
Console.WriteLine(root.ToString());