I am trying to create Xml file. I want to create node in loops
Below code what i make it to create
XDocument doc = new XDocument( new XElement("Bill", new XElement("ITEM", new XElement("Mat", new XElement("ID","1"), new XElement("Code"), new XElement("Name") ),//Mat new XElement("Store", new XElement("ID","1"), new XElement("Code"), new XElement("Name") ) )//ITEM )//Bill ); doc.save("Test.xml");
Output
<Bill>
<Version>1.0</Version>
<ITEM>
<Mat>
<ID>1<ID/>
<Code />
<Name />
</Mat>
<Store>
<ID>1<ID/>
<Code />
<Name />
</Store>
</ITEM>
</Bill>
I need to be like below Output
<Bill>
<Version>1.0</Version>
<ITEM>
<Mat>
<ID>1<ID/>
<Code />
<Name />
</Mat>
<Store>
<ID>1<ID/>
<Code />
<Name />
</Store>
</ITEM>
<ITEM>
<Mat>
<ID>2<ID/>
<Code />
<Name />
</Mat>
<Store>
<ID>2<ID/>
<Code />
<Name />
</Store>
</ITEM>
<ITEM>
<Mat>
<ID>3<ID/>
<Code />
<Name />
</Mat>
<Store>
<ID>3<ID/>
<Code />
<Name />
</Store>
</ITEM>
</Bill>
Note
I will get the value from db and pass it to xml nodes of (ID,Code,Name). I want to iterate in loop..