Using C# and LINQ
-
Friday, August 10, 2012 8:20 PM
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.
<?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> ...
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.3they want the output to look like:
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
_PrepaymentSpeedValue=
accordingly AND to combine similar columns like 126 and 200%.

