I have to update XML of table based on some conditions of that XML. Sample XML:
<CountryValues>
<CountryRow>
<CountryName>Brazil</CountryName>
<PlaceName>Place 1</PlaceName>
<Month>1</Month>
<PlaceValue>0</PlaceValue>
</CountryRow>
<CountryRow>
<CountryName>Brazil</CountryName>
<PlaceName>Place 1</PlaceName>
<Month>2</Month>
<PlaceValue>0</PlaceValue>
</CountryRow>
<CountryRow>
<CountryName>Brazil</CountryName>
<PlaceName>Place 1</PlaceName>
<Month>3</Month>
<PlaceValue>0</PlaceValue>
</CountryRow>
<CountryRow>
<CountryName>Brazil</CountryName>
<PlaceName>Place 1</PlaceName>
<Month>4</Month>
<PlaceValue>10</PlaceValue>
</CountryRow>
<CountryRow>
<CountryName>Australia</CountryName>
<PlaceName>Place 1</PlaceName>
<Month>1</Month>
<PlaceValue>0</PlaceValue>
</CountryRow>
<CountryRow>
<CountryName>Australia</CountryName>
<PlaceName>Place 1</PlaceName>
<Month>1</Month>
<PlaceValue>0</PlaceValue>
</CountryRow>
<CountryRow>
<CountryName>Australia</CountryName>
<PlaceName>Place 1</PlaceName>
<Month>1</Month>
<PlaceValue>4</PlaceValue>
</CountryRow>
</CountryValues>
Each Country can have multiple Places. I have to group on the basis of Country and Places, then I have to update PlaceValues to null for PlaceValue = 0 except 0 which is immediately preceding PlaceValue > 1. Example in this sample, for Country = Brazil and PlaceName = 1, PlaceValue for Month1 to Month2 will be Null but Month3 will remain 0 as its preceding Month4 which is greate than 0.