How to rearrange attributes of an XML using vb.net
Frage
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>
Lösung
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")))
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow