Is it possible to create the following XML using Xdocument(C#3.0)
Posted
by Newbie
on Stack Overflow
See other posts from Stack Overflow
or by Newbie
Published on 2010-06-03T03:10:22Z
Indexed on
2010/06/03
3:14 UTC
Read the original article
Hit count: 165
c#3.0
|linq-to-xml
<?xml version='1.0' encoding='UTF-8'?>
<StockMarket>
<StockDate Day = "02" Month="06" Year="2010">
<Stock>
<Symbol>ABC</Symbol>
<Amount>110.45</Amount>
</Stock>
<Stock>
<Symbol>XYZ</Symbol>
<Amount>366.25</Amount>
</Stock>
</StockDate>
<StockDate Day = "03" Month="06" Year="2010">
<Stock>
<Symbol>ABC</Symbol>
<Amount>110.35</Amount>
</Stock>
<Stock>
<Symbol>XYZ</Symbol>
<Amount>369.70</Amount>
</Stock>
</StockDate>
</StockMarket>
My approach so far is
XDocument doc =
new XDocument(
new XElement("StockMarket",
new XElement("StockDate", new XAttribute("Day", "02"),new XAttribute("Month","06"),new XAttribute("Year","2010")),
new XElement("Stock")
)
);
Since I am new to Linq to XML, I am presently struggling a lot and henceforth seeking for help.
Using C#3.0 .
Thanks
© Stack Overflow or respective owner