Pergunta

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>
Foi útil?

Solução

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top