Конвертация файла XML в формат CSV - C#

Узнай цену своей работы

Формулировка задачи:

Добрый день. Уважаемые знатоки, помогите сконвертировать XML в CSV. Пытался разобраться с сереализацией/десериализацией, но так и не понял схему развертывания в строку. Так же пытался распарсить XML в CSV, но все так же без успешно.
<?xml version="1.0" encoding="utf-8"?>
<root>
  <DB bulletinDate="2014-04-01T00:00:00.0000000+06:00">
    <option name="OG PUT GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1280" SettPrice="18.60" Delta="0.4928" VolumeTradesCleared="180" PntVolume="100" OpenInterest="517" OpenInterestChange="46" />
        <Strike StrikeValue="1300" SettPrice="30.20" Delta="0.6637" VolumeTradesCleared="314" PntVolume="100" OpenInterest="3103" OpenInterestChange="-189" />
      </contract>
      <contract date="2014-06-01T00:00:00">
        <Strike StrikeValue="1200" SettPrice="7.40" Delta="0.1573" VolumeTradesCleared="214" PntVolume="500" OpenInterest="8311" OpenInterestChange="228" />
        <Strike StrikeValue="1230" SettPrice="12.80" Delta="0.2528" VolumeTradesCleared="5" PntVolume="300" OpenInterest="1372" OpenInterestChange="-245" />
        <Strike StrikeValue="1275" SettPrice="28.00" Delta="0.4618" VolumeTradesCleared="87" PntVolume="100" OpenInterest="8345" OpenInterestChange="-6" />
        <Strike StrikeValue="1300" SettPrice="41.20" Delta="0.5940" VolumeTradesCleared="131" PntVolume="125" OpenInterest="6616" OpenInterestChange="-37" />
      </contract>
      <contract date="2014-08-01T00:00:00">
        <Strike StrikeValue="1200" SettPrice="18.20" Delta="0.2366" VolumeTradesCleared="24" PntVolume="700" OpenInterest="8094" OpenInterestChange="700" />
      </contract>
      <contract date="2014-10-01T00:00:00">
        <Strike StrikeValue="1150" SettPrice="16.70" Delta="0.1791" VolumeTradesCleared="2" PntVolume="210" OpenInterest="1785" OpenInterestChange="-90" />
        <Strike StrikeValue="1300" SettPrice="68.50" Delta="0.5305" VolumeTradesCleared="0" PntVolume="140" OpenInterest="1154" OpenInterestChange="40" />
      </contract>
      <contract date="2014-12-01T00:00:00">
        <Strike StrikeValue="1290" SettPrice="72.50" Delta="0.4944" VolumeTradesCleared="1" PntVolume="250" OpenInterest="358" OpenInterestChange="239" />
      </contract>
      <contract date="2015-02-01T00:00:00">
        <Strike StrikeValue="1075" SettPrice="17.30" Delta="0.1385" VolumeTradesCleared="0" PntVolume="435" OpenInterest="1085" OpenInterestChange="335" />
      </contract>
      <contract date="2017-06-01T00:00:00">
        <Strike StrikeValue="1125" SettPrice="85.50" Delta="0.2604" VolumeTradesCleared="0" PntVolume="500" OpenInterest="500" OpenInterestChange="500" />
      </contract>
    </option>
    <option name="OG CALL GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1340" SettPrice="2.70" Delta="0.1110" VolumeTradesCleared="50" PntVolume="100" OpenInterest="1481" OpenInterestChange="83" />
      </contract>
      <contract date="2014-06-01T00:00:00">
        <Strike StrikeValue="1275" SettPrice="33.00" Delta="0.5381" VolumeTradesCleared="66" PntVolume="100" OpenInterest="1417" OpenInterestChange="65" />
        <Strike StrikeValue="1300" SettPrice="21.20" Delta="0.4059" VolumeTradesCleared="404" PntVolume="300" OpenInterest="4590" OpenInterestChange="510" />
        <Strike StrikeValue="1340" SettPrice="9.70" Delta="0.2256" VolumeTradesCleared="1" PntVolume="300" OpenInterest="2874" OpenInterestChange="200" />
        <Strike StrikeValue="1500" SettPrice="0.80" Delta="0.0212" VolumeTradesCleared="112" PntVolume="100" OpenInterest="8435" OpenInterestChange="-42" />
        <Strike StrikeValue="1600" SettPrice="0.30" Delta="0.0075" VolumeTradesCleared="33" PntVolume="200" OpenInterest="5637" OpenInterestChange="-90" />
        <Strike StrikeValue="1700" SettPrice="0.20" Delta="0.0044" VolumeTradesCleared="14" PntVolume="100" OpenInterest="5098" OpenInterestChange="89" />
      </contract>
      <contract date="2014-08-01T00:00:00">
        <Strike StrikeValue="1300" SettPrice="36.90" Delta="0.4493" VolumeTradesCleared="5" PntVolume="500" OpenInterest="6272" OpenInterestChange="450" />
        <Strike StrikeValue="1450" SettPrice="6.40" Delta="0.1092" VolumeTradesCleared="53" PntVolume="1700" OpenInterest="6355" OpenInterestChange="1103" />
        <Strike StrikeValue="1600" SettPrice="1.80" Delta="0.0314" VolumeTradesCleared="0" PntVolume="500" OpenInterest="6946" OpenInterestChange="500" />
      </contract>
      <contract date="2014-10-01T00:00:00">
        <Strike StrikeValue="1360" SettPrice="28.50" Delta="0.3184" VolumeTradesCleared="1" PntVolume="290" OpenInterest="391" OpenInterestChange="291" />
      </contract>
      <contract date="2014-12-01T00:00:00">
        <Strike StrikeValue="1290" SettPrice="63.60" Delta="0.5055" VolumeTradesCleared="1" PntVolume="250" OpenInterest="376" OpenInterestChange="251" />
        <Strike StrikeValue="1500" SettPrice="13.60" Delta="0.1512" VolumeTradesCleared="10" PntVolume="200" OpenInterest="6009" OpenInterestChange="140" />
        <Strike StrikeValue="1600" SettPrice="7.30" Delta="0.0852" VolumeTradesCleared="1" PntVolume="100" OpenInterest="11064" OpenInterestChange="-99" />
        <Strike StrikeValue="1700" SettPrice="4.20" Delta="0.0502" VolumeTradesCleared="0" PntVolume="200" OpenInterest="22962" OpenInterestChange="86" />
      </contract>
      <contract date="2017-06-01T00:00:00">
        <Strike StrikeValue="1800" SettPrice="52.00" Delta="0.2313" VolumeTradesCleared="0" PntVolume="500" OpenInterest="500" OpenInterestChange="500" />
      </contract>
    </option>
  </DB>
  <DB bulletinDate="2014-04-02T00:00:00.0000000+06:00">
    <option name="OG PUT GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1210" SettPrice="1.40" Delta="0.0552" VolumeTradesCleared="41" PntVolume="100" OpenInterest="567" OpenInterestChange="119" />
        <Strike StrikeValue="1230" SettPrice="2.60" Delta="0.1006" VolumeTradesCleared="27" PntVolume="100" OpenInterest="975" OpenInterestChange="110" />
        <Strike StrikeValue="1250" SettPrice="4.80" Delta="0.1788" VolumeTradesCleared="563" PntVolume="150" OpenInterest="5807" OpenInterestChange="105" />
        <Strike StrikeValue="1300" SettPrice="22.40" Delta="0.5788" VolumeTradesCleared="315" PntVolume="200" OpenInterest="2990" OpenInterestChange="-113" />
      </contract>
      <contract date="2014-06-01T00:00:00">
        <Strike StrikeValue="1210" SettPrice="6.80" Delta="0.1497" VolumeTradesCleared="3" PntVolume="100" OpenInterest="2263" OpenInterestChange="74" />
        <Strike StrikeValue="1230" SettPrice="9.80" Delta="0.2076" VolumeTradesCleared="1" PntVolume="100" OpenInterest="1471" OpenInterestChange="99" />
      </contract>
      <contract date="2015-03-01T00:00:00">
        <Strike StrikeValue="1000" SettPrice="10.70" Delta="0.0829" VolumeTradesCleared="0" PntVolume="75" OpenInterest="75" OpenInterestChange="75" />
      </contract>
      <contract date="2015-04-01T00:00:00">
        <Strike StrikeValue="1300" SettPrice="89.30" Delta="0.4793" VolumeTradesCleared="0" PntVolume="200" OpenInterest="220" OpenInterestChange="190" />
      </contract>
      <contract date="2015-06-01T00:00:00">
        <Strike StrikeValue="1000" SettPrice="14.90" Delta="0.1000" VolumeTradesCleared="0" PntVolume="125" OpenInterest="650" OpenInterestChange="0" />
      </contract>
      <contract date="2015-09-01T00:00:00">
        <Strike StrikeValue="1000" SettPrice="19.00" Delta="0.1133" VolumeTradesCleared="0" PntVolume="75" OpenInterest="75" OpenInterestChange="75" />
      </contract>
      <contract date="2015-12-01T00:00:00">
        <Strike StrikeValue="1000" SettPrice="25.10" Delta="0.1300" VolumeTradesCleared="0" PntVolume="25" OpenInterest="2600" OpenInterestChange="0" />
      </contract>
    </option>
    <option name="OG CALL GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1325" SettPrice="5.80" Delta="0.2235" VolumeTradesCleared="135" PntVolume="100" OpenInterest="1902" OpenInterestChange="-24" />
        <Strike StrikeValue="1450" SettPrice="0.30" Delta="0.0114" VolumeTradesCleared="2" PntVolume="150" OpenInterest="5315" OpenInterestChange="48" />
      </contract>
      <contract date="2014-08-01T00:00:00">
        <Strike StrikeValue="1300" SettPrice="41.00" Delta="0.4860" VolumeTradesCleared="31" PntVolume="50" OpenInterest="6317" OpenInterestChange="45" />
      </contract>
      <contract date="2014-12-01T00:00:00">
        <Strike StrikeValue="1400" SettPrice="29.60" Delta="0.2936" VolumeTradesCleared="0" PntVolume="406" OpenInterest="8060" OpenInterestChange="327" />
        <Strike StrikeValue="1500" SettPrice="14.50" Delta="0.1604" VolumeTradesCleared="0" PntVolume="406" OpenInterest="5740" OpenInterestChange="-269" />
      </contract>
      <contract date="2015-03-01T00:00:00">
        <Strike StrikeValue="2000" SettPrice="2.40" Delta="0.001" VolumeTradesCleared="0" PntVolume="75" OpenInterest="75" OpenInterestChange="75" />
      </contract>
      <contract date="2015-04-01T00:00:00">
        <Strike StrikeValue="1300" SettPrice="82.60" Delta="0.5206" VolumeTradesCleared="0" PntVolume="200" OpenInterest="207" OpenInterestChange="200" />
      </contract>
      <contract date="2015-06-01T00:00:00">
        <Strike StrikeValue="2000" SettPrice="4.60" Delta="0.0405" VolumeTradesCleared="0" PntVolume="125" OpenInterest="150" OpenInterestChange="-50" />
      </contract>
      <contract date="2015-09-01T00:00:00">
        <Strike StrikeValue="2000" SettPrice="6.90" Delta="0.001" VolumeTradesCleared="0" PntVolume="75" OpenInterest="75" OpenInterestChange="75" />
      </contract>
      <contract date="2015-12-01T00:00:00">
        <Strike StrikeValue="2000" SettPrice="10.40" Delta="0.0730" VolumeTradesCleared="0" PntVolume="75" OpenInterest="12405" OpenInterestChange="50" />
      </contract>
    </option>
  </DB>
  <DB bulletinDate="2014-04-03T00:00:00.0000000+06:00">
    <option name="OG PUT GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1285" SettPrice="17.30" Delta="0.4973" VolumeTradesCleared="35" PntVolume="100" OpenInterest="846" OpenInterestChange="-19" />
      </contract>
      <contract date="2014-06-01T00:00:00">
        <Strike StrikeValue="1050" SettPrice="0.70" Delta="0.0147" VolumeTradesCleared="0" PntVolume="495" OpenInterest="3038" OpenInterestChange="0" />
        <Strike StrikeValue="1150" SettPrice="2.60" Delta="0.0601" VolumeTradesCleared="40" PntVolume="330" OpenInterest="3608" OpenInterestChange="-325" />
        <Strike StrikeValue="1200" SettPrice="6.10" Delta="0.1375" VolumeTradesCleared="12" PntVolume="800" OpenInterest="9110" OpenInterestChange="790" />
        <Strike StrikeValue="1280" SettPrice="26.40" Delta="0.4631" VolumeTradesCleared="15" PntVolume="800" OpenInterest="3625" OpenInterestChange="-2" />
      </contract>
      <contract date="2014-07-01T00:00:00">
        <Strike StrikeValue="1250" SettPrice="22.60" Delta="0.3407" VolumeTradesCleared="10" PntVolume="150" OpenInterest="2795" OpenInterestChange="150" />
      </contract>
      <contract date="2014-08-01T00:00:00">
        <Strike StrikeValue="1200" SettPrice="16.20" Delta="0.2201" VolumeTradesCleared="10" PntVolume="375" OpenInterest="8469" OpenInterestChange="375" />
      </contract>
      <contract date="2015-04-01T00:00:00">
        <Strike StrikeValue="1160" SettPrice="36.70" Delta="0.2484" VolumeTradesCleared="0" PntVolume="220" OpenInterest="250" OpenInterestChange="250" />
      </contract>
    </option>
    <option name="OG CALL GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1285" SettPrice="16.90" Delta="0.5026" VolumeTradesCleared="60" PntVolume="100" OpenInterest="531" OpenInterestChange="38" />
        <Strike StrikeValue="1290" SettPrice="14.60" Delta="0.4553" VolumeTradesCleared="126" PntVolume="100" OpenInterest="482" OpenInterestChange="173" />
        <Strike StrikeValue="1300" SettPrice="10.50" Delta="0.3626" VolumeTradesCleared="89" PntVolume="100" OpenInterest="3142" OpenInterestChange="51" />
        <Strike StrikeValue="1325" SettPrice="4.30" Delta="0.1785" VolumeTradesCleared="174" PntVolume="75" OpenInterest="2021" OpenInterestChange="119" />
        <Strike StrikeValue="1340" SettPrice="2.50" Delta="0.1105" VolumeTradesCleared="34" PntVolume="200" OpenInterest="1454" OpenInterestChange="-44" />
      </contract>
      <contract date="2014-06-01T00:00:00">
        <Strike StrikeValue="1350" SettPrice="7.60" Delta="0.1931" VolumeTradesCleared="332" PntVolume="150" OpenInterest="3515" OpenInterestChange="-151" />
      </contract>
      <contract date="2014-08-01T00:00:00">
        <Strike StrikeValue="1290" SettPrice="41.90" Delta="0.4988" VolumeTradesCleared="9" PntVolume="250" OpenInterest="999" OpenInterestChange="437" />
      </contract>
      <contract date="2014-12-01T00:00:00">
        <Strike StrikeValue="1300" SettPrice="60.50" Delta="0.4922" VolumeTradesCleared="315" PntVolume="700" OpenInterest="5603" OpenInterestChange="730" />
        <Strike StrikeValue="1400" SettPrice="27.70" Delta="0.2807" VolumeTradesCleared="510" PntVolume="700" OpenInterest="9055" OpenInterestChange="995" />
      </contract>
      <contract date="2015-04-01T00:00:00">
        <Strike StrikeValue="1465" SettPrice="29.40" Delta="0.2467" VolumeTradesCleared="0" PntVolume="220" OpenInterest="250" OpenInterestChange="250" />
      </contract>
    </option>
  </DB>
  <DB bulletinDate="2014-04-04T00:00:00.0000000+06:00">
    <option name="OG PUT GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1250" SettPrice="2.60" Delta="0.1087" VolumeTradesCleared="364" PntVolume="50" OpenInterest="5983" OpenInterestChange="153" />
      </contract>
      <contract date="2014-06-01T00:00:00">
        <Strike StrikeValue="1225" SettPrice="6.40" Delta="0.1474" VolumeTradesCleared="172" PntVolume="227" OpenInterest="1763" OpenInterestChange="207" />
        <Strike StrikeValue="1295" SettPrice="24.30" Delta="0.4412" VolumeTradesCleared="121" PntVolume="100" OpenInterest="327" OpenInterestChange="119" />
      </contract>
      <contract date="2014-07-01T00:00:00">
        <Strike StrikeValue="1250" SettPrice="16.60" Delta="0.2702" VolumeTradesCleared="612" PntVolume="50" OpenInterest="2992" OpenInterestChange="197" />
        <Strike StrikeValue="1310" SettPrice="39.40" Delta="0.5136" VolumeTradesCleared="5" PntVolume="200" OpenInterest="1608" OpenInterestChange="569" />
      </contract>
      <contract date="2014-10-01T00:00:00">
        <Strike StrikeValue="1250" SettPrice="34.00" Delta="0.3316" VolumeTradesCleared="0" PntVolume="725" OpenInterest="2572" OpenInterestChange="401" />
      </contract>
      <contract date="2014-11-01T00:00:00">
        <Strike StrikeValue="1000" SettPrice="4.40" Delta="0.0458" VolumeTradesCleared="0" PntVolume="1650" OpenInterest="2045" OpenInterestChange="1045" />
      </contract>
      <contract date="2014-12-01T00:00:00">
        <Strike StrikeValue="1200" SettPrice="28.30" Delta="0.2481" VolumeTradesCleared="4" PntVolume="500" OpenInterest="8976" OpenInterestChange="-400" />
      </contract>
      <contract date="2015-06-01T00:00:00">
        <Strike StrikeValue="1000" SettPrice="14.10" Delta="0.0941" VolumeTradesCleared="0" PntVolume="420" OpenInterest="1070" OpenInterestChange="420" />
        <Strike StrikeValue="1315" SettPrice="96.20" Delta="0.4794" VolumeTradesCleared="0" PntVolume="150" OpenInterest="150" OpenInterestChange="150" />
      </contract>
    </option>
    <option name="OG CALL GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1350" SettPrice="3.10" Delta="0.1383" VolumeTradesCleared="599" PntVolume="50" OpenInterest="4849" OpenInterestChange="117" />
      </contract>
      <contract date="2014-06-01T00:00:00">
        <Strike StrikeValue="1295" SettPrice="32.80" Delta="0.5587" VolumeTradesCleared="20" PntVolume="100" OpenInterest="299" OpenInterestChange="113" />
        <Strike StrikeValue="1375" SettPrice="6.70" Delta="0.1733" VolumeTradesCleared="126" PntVolume="227" OpenInterest="1408" OpenInterestChange="190" />
      </contract>
      <contract date="2014-07-01T00:00:00">
        <Strike StrikeValue="1300" SettPrice="38.30" Delta="0.5305" VolumeTradesCleared="15" PntVolume="100" OpenInterest="1563" OpenInterestChange="-71" />
        <Strike StrikeValue="1310" SettPrice="33.20" Delta="0.4863" VolumeTradesCleared="39" PntVolume="200" OpenInterest="1686" OpenInterestChange="563" />
        <Strike StrikeValue="1400" SettPrice="8.40" Delta="0.1701" VolumeTradesCleared="49" PntVolume="200" OpenInterest="2647" OpenInterestChange="7" />
      </contract>
      <contract date="2014-10-01T00:00:00">
        <Strike StrikeValue="1350" SettPrice="37.10" Delta="0.3945" VolumeTradesCleared="0" PntVolume="725" OpenInterest="1155" OpenInterestChange="443" />
      </contract>
      <contract date="2014-12-01T00:00:00">
        <Strike StrikeValue="1400" SettPrice="31.60" Delta="0.3127" VolumeTradesCleared="413" PntVolume="2150" OpenInterest="9556" OpenInterestChange="501" />
        <Strike StrikeValue="1600" SettPrice="7.80" Delta="0.0924" VolumeTradesCleared="27" PntVolume="80" OpenInterest="11153" OpenInterestChange="87" />
        <Strike StrikeValue="1900" SettPrice="1.70" Delta="0.0208" VolumeTradesCleared="2" PntVolume="390" OpenInterest="26719" OpenInterestChange="0" />
        <Strike StrikeValue="2000" SettPrice="1.10" Delta="0.0135" VolumeTradesCleared="0" PntVolume="460" OpenInterest="29132" OpenInterestChange="-448" />
      </contract>
      <contract date="2015-06-01T00:00:00">
        <Strike StrikeValue="1315" SettPrice="87.80" Delta="0.5205" VolumeTradesCleared="0" PntVolume="150" OpenInterest="150" OpenInterestChange="150" />
        <Strike StrikeValue="1715" SettPrice="13.10" Delta="0.1098" VolumeTradesCleared="0" PntVolume="420" OpenInterest="420" OpenInterestChange="420" />
      </contract>
      <contract date="2016-06-01T00:00:00">
        <Strike StrikeValue="1600" SettPrice="49.00" Delta="0.2672" VolumeTradesCleared="0" PntVolume="150" OpenInterest="150" OpenInterestChange="150" />
      </contract>
    </option>
  </DB>
  <DB bulletinDate="2014-04-07T00:00:00.0000000+06:00">
    <option name="OG PUT GOLD OPTIONS">
      <contract date="2014-08-01T00:00:00">
        <Strike StrikeValue="1150" SettPrice="6.60" Delta="0.1016" VolumeTradesCleared="16" PntVolume="840" OpenInterest="8727" OpenInterestChange="480" />
        <Strike StrikeValue="1300" SettPrice="44.10" Delta="0.4885" VolumeTradesCleared="3" PntVolume="300" OpenInterest="3218" OpenInterestChange="192" />
      </contract>
      <contract date="2014-10-01T00:00:00">
        <Strike StrikeValue="1100" SettPrice="7.80" Delta="0.0918" VolumeTradesCleared="400" PntVolume="256" OpenInterest="2049" OpenInterestChange="200" />
        <Strike StrikeValue="1200" SettPrice="21.00" Delta="0.2276" VolumeTradesCleared="0" PntVolume="500" OpenInterest="1273" OpenInterestChange="429" />
        <Strike StrikeValue="1250" SettPrice="35.00" Delta="0.3432" VolumeTradesCleared="200" PntVolume="128" OpenInterest="2672" OpenInterestChange="100" />
      </contract>
      <contract date="2015-12-01T00:00:00">
        <Strike StrikeValue="950" SettPrice="16.90" Delta="0.0926" VolumeTradesCleared="0" PntVolume="1500" OpenInterest="2006" OpenInterestChange="1980" />
        <Strike StrikeValue="1330" SettPrice="124.70" Delta="0.4922" VolumeTradesCleared="0" PntVolume="500" OpenInterest="1245" OpenInterestChange="500" />
      </contract>
    </option>
    <option name="OG CALL GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1320" SettPrice="7.20" Delta="0.2905" VolumeTradesCleared="390" PntVolume="250" OpenInterest="1499" OpenInterestChange="-117" />
      </contract>
      <contract date="2014-08-01T00:00:00">
        <Strike StrikeValue="1300" SettPrice="42.70" Delta="0.5114" VolumeTradesCleared="31" PntVolume="300" OpenInterest="6233" OpenInterestChange="-84" />
        <Strike StrikeValue="1475" SettPrice="4.80" Delta="0.0890" VolumeTradesCleared="0" PntVolume="840" OpenInterest="1144" OpenInterestChange="814" />
      </contract>
      <contract date="2014-10-01T00:00:00">
        <Strike StrikeValue="1400" SettPrice="21.10" Delta="0.2608" VolumeTradesCleared="0" PntVolume="500" OpenInterest="1707" OpenInterestChange="405" />
      </contract>
      <contract date="2015-12-01T00:00:00">
        <Strike StrikeValue="1330" SettPrice="100.30" Delta="0.5077" VolumeTradesCleared="0" PntVolume="500" OpenInterest="1248" OpenInterestChange="500" />
        <Strike StrikeValue="1850" SettPrice="15.30" Delta="0.1063" VolumeTradesCleared="0" PntVolume="1500" OpenInterest="1816" OpenInterestChange="1500" />
      </contract>
    </option>
  </DB>
  <DB bulletinDate="2014-04-08T00:00:00.0000000+06:00">
    <option name="OG PUT GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1275" SettPrice="4.50" Delta="0.1882" VolumeTradesCleared="58" PntVolume="75" OpenInterest="2273" OpenInterestChange="95" />
      </contract>
      <contract date="2014-07-01T00:00:00">
        <Strike StrikeValue="1125" SettPrice="2.50" Delta="0.0465" VolumeTradesCleared="0" PntVolume="1275" OpenInterest="1703" OpenInterestChange="1125" />
        <Strike StrikeValue="1225" SettPrice="10.30" Delta="0.1806" VolumeTradesCleared="87" PntVolume="850" OpenInterest="1080" OpenInterestChange="628" />
      </contract>
      <contract date="2014-08-01T00:00:00">
        <Strike StrikeValue="1200" SettPrice="11.20" Delta="0.1635" VolumeTradesCleared="22" PntVolume="100" OpenInterest="8462" OpenInterestChange="0" />
        <Strike StrikeValue="1250" SettPrice="21.40" Delta="0.2834" VolumeTradesCleared="30" PntVolume="100" OpenInterest="4721" OpenInterestChange="60" />
      </contract>
      <contract date="2014-11-01T00:00:00">
        <Strike StrikeValue="1110" SettPrice="10.70" Delta="0.1098" VolumeTradesCleared="0" PntVolume="788" OpenInterest="788" OpenInterestChange="788" />
        <Strike StrikeValue="1320" SettPrice="67.10" Delta="0.5015" VolumeTradesCleared="0" PntVolume="350" OpenInterest="356" OpenInterestChange="350" />
      </contract>
      <contract date="2014-12-01T00:00:00">
        <Strike StrikeValue="1320" SettPrice="71.80" Delta="0.4980" VolumeTradesCleared="0" PntVolume="400" OpenInterest="758" OpenInterestChange="400" />
      </contract>
      <contract date="2018-06-01T00:00:00">
        <Strike StrikeValue="1475" SettPrice="247.10" Delta="0.5036" VolumeTradesCleared="0" PntVolume="600" OpenInterest="600" OpenInterestChange="600" />
      </contract>
    </option>
    <option name="OG CALL GOLD OPTIONS">
      <contract date="2014-07-01T00:00:00">
        <Strike StrikeValue="1440" SettPrice="5.00" Delta="0.1075" VolumeTradesCleared="0" PntVolume="1275" OpenInterest="1424" OpenInterestChange="1271" />
      </contract>
      <contract date="2014-10-01T00:00:00">
        <Strike StrikeValue="1350" SettPrice="38.90" Delta="0.4088" VolumeTradesCleared="0" PntVolume="50" OpenInterest="1180" OpenInterestChange="25" />
      </contract>
      <contract date="2014-11-01T00:00:00">
        <Strike StrikeValue="1320" SettPrice="57.40" Delta="0.4984" VolumeTradesCleared="0" PntVolume="350" OpenInterest="350" OpenInterestChange="350" />
        <Strike StrikeValue="1580" SettPrice="7.30" Delta="0.0927" VolumeTradesCleared="0" PntVolume="788" OpenInterest="797" OpenInterestChange="788" />
      </contract>
      <contract date="2014-12-01T00:00:00">
        <Strike StrikeValue="1320" SettPrice="62.00" Delta="0.5019" VolumeTradesCleared="0" PntVolume="400" OpenInterest="433" OpenInterestChange="400" />
        <Strike StrikeValue="1400" SettPrice="33.20" Delta="0.3241" VolumeTradesCleared="18" PntVolume="75" OpenInterest="9602" OpenInterestChange="41" />
        <Strike StrikeValue="1500" SettPrice="15.60" Delta="0.1739" VolumeTradesCleared="3" PntVolume="75" OpenInterest="5841" OpenInterestChange="-74" />
      </contract>
      <contract date="2018-06-01T00:00:00">
        <Strike StrikeValue="1475" SettPrice="156.90" Delta="0.4963" VolumeTradesCleared="0" PntVolume="600" OpenInterest="600" OpenInterestChange="600" />
      </contract>
    </option>
  </DB>
  <DB bulletinDate="2014-04-09T00:00:00.0000000+06:00">
    <option name="OG PUT GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1300" SettPrice="11.10" Delta="0.4252" VolumeTradesCleared="699" PntVolume="150" OpenInterest="2752" OpenInterestChange="-158" />
      </contract>
      <contract date="2014-06-01T00:00:00">
        <Strike StrikeValue="1255" SettPrice="9.30" Delta="0.2206" VolumeTradesCleared="13" PntVolume="500" OpenInterest="784" OpenInterestChange="13" />
        <Strike StrikeValue="1285" SettPrice="17.40" Delta="0.3659" VolumeTradesCleared="98" PntVolume="400" OpenInterest="926" OpenInterestChange="67" />
        <Strike StrikeValue="1290" SettPrice="19.20" Delta="0.3943" VolumeTradesCleared="113" PntVolume="500" OpenInterest="1429" OpenInterestChange="-487" />
        <Strike StrikeValue="1300" SettPrice="23.30" Delta="0.4538" VolumeTradesCleared="146" PntVolume="150" OpenInterest="6202" OpenInterestChange="147" />
        <Strike StrikeValue="1315" SettPrice="30.80" Delta="0.5463" VolumeTradesCleared="16" PntVolume="800" OpenInterest="1493" OpenInterestChange="0" />
        <Strike StrikeValue="1330" SettPrice="39.80" Delta="0.6365" VolumeTradesCleared="0" PntVolume="400" OpenInterest="1020" OpenInterestChange="-400" />
        <Strike StrikeValue="1335" SettPrice="43.20" Delta="0.6644" VolumeTradesCleared="0" PntVolume="350" OpenInterest="1084" OpenInterestChange="0" />
        <Strike StrikeValue="1340" SettPrice="46.70" Delta="0.6915" VolumeTradesCleared="0" PntVolume="350" OpenInterest="1351" OpenInterestChange="-350" />
      </contract>
      <contract date="2014-08-01T00:00:00">
        <Strike StrikeValue="1225" SettPrice="15.30" Delta="0.2199" VolumeTradesCleared="0" PntVolume="100" OpenInterest="1233" OpenInterestChange="0" />
      </contract>
      <contract date="2014-10-01T00:00:00">
        <Strike StrikeValue="1225" SettPrice="24.70" Delta="0.2630" VolumeTradesCleared="0" PntVolume="100" OpenInterest="100" OpenInterestChange="100" />
      </contract>
      <contract date="2014-12-01T00:00:00">
        <Strike StrikeValue="1315" SettPrice="69.20" Delta="0.4950" VolumeTradesCleared="0" PntVolume="1500" OpenInterest="1701" OpenInterestChange="1500" />
        <Strike StrikeValue="1385" SettPrice="113.00" Delta="0.6569" VolumeTradesCleared="0" PntVolume="400" OpenInterest="401" OpenInterestChange="200" />
      </contract>
      <contract date="2015-06-01T00:00:00">
        <Strike StrikeValue="1170" SettPrice="40.10" Delta="0.2461" VolumeTradesCleared="0" PntVolume="50" OpenInterest="50" OpenInterestChange="50" />
        <Strike StrikeValue="1230" SettPrice="57.70" Delta="0.3323" VolumeTradesCleared="0" PntVolume="50" OpenInterest="50" OpenInterestChange="50" />
      </contract>
    </option>
    <option name="OG CALL GOLD OPTIONS">
      <contract date="2014-05-01T00:00:00">
        <Strike StrikeValue="1340" SettPrice="3.10" Delta="0.1613" VolumeTradesCleared="459" PntVolume="50" OpenInterest="1737" OpenInterestChange="288" />
      </contract>
      <contract date="2014-06-01T00:00:00">
        <Strike StrikeValue="1255" SettPrice="60.20" Delta="0.7793" VolumeTradesCleared="0" PntVolume="500" OpenInterest="503" OpenInterestChange="0" />
        <Strike StrikeValue="1285" SettPrice="38.30" Delta="0.6340" VolumeTradesCleared="0" PntVolume="400" OpenInterest="762" OpenInterestChange="0" />
        <Strike StrikeValue="1290" SettPrice="35.10" Delta="0.6056" VolumeTradesCleared="1" PntVolume="500" OpenInterest="640" OpenInterestChange="-14" />
        <Strike StrikeValue="1315" SettPrice="21.70" Delta="0.4536" VolumeTradesCleared="48" PntVolume="800&

Решение задачи: «Конвертация файла XML в формат CSV»

textual
Листинг программы
string XmlToCsv(string file)
{
   var xml = XDocument.Load(file);
 
   // Сбор заголовков
   var headers = new StringBuilder();
   var root = xml.Root;
   while (root != null)
   {
       foreach (var attribute in root.Attributes())
           headers.Append(attribute.Name.LocalName).Append(',');
       root = root.Elements().FirstOrDefault();
   }
   headers.Length--;
 
   // Развертывание структуры
   var q = from db in xml.Root.Elements()
        from option in db.Elements()
        from contract in option.Elements()
        from strike in contract.Elements()
 
        select string.Join(",", db.Attributes()
        .Concat(option.Attributes())
        .Concat(contract.Attributes())
        .Concat(strike.Attributes())
        .Select(att => att.Value));
 
   foreach (var line in q)
       buffer.AppendLine(line);
   return buffer.ToString();
}

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

11   голосов , оценка 4.364 из 5
Похожие ответы