Extracting the attributes when the occurance of them is not particular
===

I am working on the  extracting the values background color and width attributes from "td" of a table.

There are several ways of occurance of Back ground color and width. T

I have following set of valid elements.

		1.<td style="BACKGROUND-COLOR: yellow; WIDTH: 52%"></td>
		(combination of BACKGROUND-COLOR and Width in one order)
		2.<td style="WIDTH: 52%;BACKGROUND-COLOR: green"></td>
		(combination of BACKGROUND-COLOR and Width in another order)
		3.<td style="WIDTH:52%;BACKGROUND-COLOR:    green"></td>
		(Spaces could vary from ":" and value)
		4.<td style="BACKGROUND-COLOR: gray"></td>
		(only BACKGROUND-COLOR in style)
		5.<td style="BACKGROUND-COLOR: Gray"></td>
		(Value of BACKGROUND-COLOR can be case sensitive)
		6.<td style="BACKGROUND-COLOR: #ffff00"></td>
		(value of BACKGROUND-COLOR can be hexadecimal also)
		7.<td bgcolor="#008000" style="WIDTH: 54%">
		(BACKGROUND-COLOR can occur as bgcolr also(hexadecimal code)
		8.<td bgcolor="yellow">
		(BACKGROUND-COLOR can occur as bgcolr also(string))
		
List of valid colors and their codes:(all the values are case sensitive)

	Yellow:#ffff00
	Gray:#808080
	Green:#008000

Output:
	
	1.<bgclr>Yellow</bgclr>
	 <colwidth>52</colwidth>
	
	2.<bgclr>Green</bgclr>
	  <colwidth>52</colwidth>
	 
	3. <bgclr>Green</bgclr>
	  <colwidth>52</colwidth>
	
	4.<bgclr>Gray</bgclr>
	 
	 
	5.<bgclr>Gray</bgclr>
	 
	6.<bgclr>Yellow</bgclr>
	
	7.<bgclr>Green</bgclr>
	  <colwidth>54</colwidth>
	
	8.<bgclr>Yellow</bgclr>

I have tried my level best to solve this, and it looks complicated for me.

I am also providing the valid xml file.

	<tr>
			<td style="BACKGROUND-COLOR: yellow; WIDTH: 52%"></td>
			
			<td style="WIDTH: 52%;BACKGROUND-COLOR: green"></td>
			
			<td style="WIDTH:52%;BACKGROUND-COLOR:    green"></td>
			
			<td style="BACKGROUND-COLOR: gray"></td>
			
			<td style="BACKGROUND-COLOR: Gray"></td>
			
			<td style="BACKGROUND-COLOR: #ffff00"></td>
			
			<td bgcolor="#008000" style="WIDTH: 54%"></td>
			
			<td bgcolor="yellow"></td>
			
	</tr>
	

Can any one help on this.
Thanks.