rwallacej
asked on
XML Document - reorder attributes
Hi
I have some XML file, in the document the attributes are in wrong order. How do I reorder the attributes of an element?
e.g. data...
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
needs to be
<ABC FieldA="...." FieldB="...." FieldC="..." FieldD="1"></ABC>
Thanks in advance
I have some XML file, in the document the attributes are in wrong order. How do I reorder the attributes of an element?
e.g. data...
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
needs to be
<ABC FieldA="...." FieldB="...." FieldC="..." FieldD="1"></ABC>
Thanks in advance
post the whole xml and i'll write the code which reorder the attributes
C# or vb.net?
ASKER
hi, thanks but unfortunately I can't post the XML for it contains IP.
I found a "crude" way using search/replace on InnerText - but I thought there would be a simpler way
I found a "crude" way using search/replace on InnerText - but I thought there would be a simpler way
ASKER
it would be interesting to see the code, this is XML sample (in wrong order)
<MyXML>
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
</MyXML>
correct...
<ABC FieldA="...." FieldB="...." FieldC="..." FieldD="1"></ABC>
<MyXML>
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
</MyXML>
correct...
<ABC FieldA="...." FieldB="...." FieldC="..." FieldD="1"></ABC>
can u post the xpath to the elements where you want to reorder the attribute?
for example if the xml is this:
<xml>
<config>
<settings>
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
<<settings>
</config>
</xml>
the xpath is this:
xml/config/settings/ABC
for example if the xml is this:
<xml>
<config>
<settings>
<ABC FieldB="...." FieldC="...." FieldA="..." FieldD="1"></ABC>
<<settings>
</config>
</xml>
the xpath is this:
xml/config/settings/ABC
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
great help thanks