MS SQL Server 2012 Schema Setup:
create table YourTable
(
Country varchar(20),
ID int,
[1950] numeric(5,2),
[1955] numeric(5,2)
)
insert into YourTable values
('Country 1', 1, 2.43, 2.55),
('Country 2', 2, 4.54, 42.15)
Query 1:
select T.Country as 'loc/@name',
T.ID as 'loc/@id',
(
select 1950 as 'data/@year',
T.[1950] as 'data/@value',
null,
1955 as 'data/@year',
T.[1955] as 'data/@value'
for xml path(''), type
) as dub
from YourTable as T
for xml path('location'), root('locations'), type
<locations>
<location>
<loc name="Country 1" id="1" />
<dub>
<data year="1950" value="2.43" />
<data year="1955" value="2.55" />
</dub>
</location>
<location>
<loc name="Country 2" id="2" />
<dub>
<data year="1950" value="4.54" />
<data year="1955" value="42.15" />
</dub>
</location>
</locations>