c# - How can i create sublist inside a xml -


i have xml dont know how can write this. because xml has got sub list inside. dont know how can write it? can me point ?

<?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> 

i write code;

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();                     } 

how can write linq xml ?

best regards.

it not hard ,try this:

var transactions=new xelement("transactions"); transactions.add(new xelement("transaction",new xelement("type",4))); transactions.add(new xelement("transaction",new xelement("type",5))); transactions.add(new xelement("transaction",new xelement("type",6))); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -