I have the following XML :-
<inventory>
<item>
<name_element>
<!--some structure-->
</name_element>
<some_element1>val1</some_element1>
<some_element2>val2</some_element2>
<!-- some more elements -->
</item>
<!-- lots of items -->
</inventory>
Now I want to convert this to :-
<inventory>
<item some_element1="val1" some_element2="val2" ... >
<name_element>
<!-- as it is -->
</name_element>
</inventory>
Basically I don’t know anything about the names/types of some_elements and any item could have any number of these elements. I do know that they are all simple types and convertible to attributes.
I’ve read Converting XML elements to XML attributes using XSLT which tells how I can convert all child elements to attributes but it’s not clear from that how I could exclude a specific ‘name_element’ from being converted to an attribute.
1 Answer