Using C# and LINQ

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have some funky xml files. First off, I have values that are not sequential in the file and duplicate values (if they exist) need to be combined, let me give you a visual of the sample input.
<pre class="prettyprint <?xml version="1.0"?>
<PRICE_YIELD_ANALYSIS _SeriesNumber="4083" _CollateralStatus="Assumed" _Source="FHLMC" _DealerName="CITIGROUP GLOBAL MARKETS, INC.
<OCS_GROUP _Number="1" _SettlementDate="2012-07-30" _FirstPaymentDate="2012-08-15
<PRICE_YIELD_UNIT>
<CLASS _Id="PJ" _AssumedPrice="30.125" _Cap="3.500000" _InitialCouponRate="3.500000" _InitialAccrualPeriod="29" _Floor="0.000000" _Multiplier="1" _OriginalUpb="6365000.000000" _Spread="131.50000"/>
<SCENARIO _PrepaymentSpeedValue="126" _PrepaymentSpeedType="PSA" _IndexRate="1" _IndexName="LIBOR_1MO"/>
<PRICE_YIELD_DETAIL _YieldPct="1.48420"/>
</PRICE_YIELD_UNIT>
<CLASS _Id="PJ" _AssumedPrice="30.125" _Cap="3.500000" _InitialCouponRate="3.500000" _InitialAccrualPeriod="29" _Floor="0.000000" _Multiplier="1" _OriginalUpb="6365000.000000" _Spread="131.50000"/>
<SCENARIO _PrepaymentSpeedValue="126" _PrepaymentSpeedType="PSA" _IndexRate="2" _IndexName="LIBOR_1MO"/>
<PRICE_YIELD_DETAIL _YieldPct="0.51789"/>
</PRICE_YIELD_UNIT>
<PRICE_YIELD_UNIT>
<CLASS _Id="PJ" _AssumedPrice="30.125" _Cap="3.500000" _InitialCouponRate="3.500000" _InitialAccrualPeriod="29" _Floor="0.000000" _Multiplier="1" _OriginalUpb="6365000.000000" _Spread="131.50000"/>
<SCENARIO _PrepaymentSpeedValue="126" _PrepaymentSpeedType="PSA" _IndexRate="3" _IndexName="LIBOR_1MO"/>
<PRICE_YIELD_DETAIL _YieldPct="5.41789"/>
</PRICE_YIELD_UNIT>
<PRICE_YIELD_UNIT>
...[/code]
<pre> 126% 200% 50% 25% 400% 500%
================================
1% 1.5 1.5 0.2 3.5 7.6 4.4
2% 0.5 0.5 3.4 5.6 7.8 9.0
3% 5.4 5.4 1.2 2.3 3.4 5.6
4% 2.3 2.3 0.9 8.7 6.5 4.3

[/code]
they want the output to look like:
<pre> 126%
thru
25% 50% 200% 400% 500%
============================
1% 3.5 0.2 1.5 7.6 4.4
2% 5.6 3.4 0.5 7.8 9.0
3% 2.3 1.2 5.4 3.4 5.6
4% 8.7 0.9 2.3 6.5 4.3 Is there any way to have linq statement sort by to order these by <pre class="prettyprint" style="font-size:1.23em; direction:ltr; padding-bottom:2px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:#888888; border-right-color:#888888; border-bottom-color:#888888; border-left-color:#888888 _PrepaymentSpeedValue=[/code] accordingly AND to combine similar columns like 126 and 200%.

[/code]

View the full article
 
Back
Top