Pregunta

I have an xml with some attributes and i want to rearrange those attributes. And i am having different elements with different attributes. I want all elements 'id' as my first attribute.

Here the small example,

<item name="product" dep="DE" id="I001">Item</item>

and i want to rearrange the attributes like

<item id="I001" name="product" dep="DE">Item</item>
¿Fue útil?

Solución

Dim x As XElement = <item name="product" dep="DE" id="I001">Item</item>

x.ReplaceAttributes(x.Attributes("id").Concat(x.Attributes().Where(Function(a) a.Name <> "id")))
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top