I have a document with

<relation>
<relationType>USE</relationType>
<termName>a name</termName>
<termId>an ID</termId>
</relation>

The system we use needs

<relation>
<termId>an ID</termId>
<termName>a name</termName>
<relationType>USE</relationType>
</relation>

Is it possible to write a regex to reorder these properties? Many thanks

link|improve this question
feedback

1 Answer

Trying to manipulate XML using regexes will lead to madness.

Use xmlstarlet instead.

But I can't see how the order should matter. That's what using named key/value pairs does for you. If the document consumer requires them in a particular order it's broken.

link|improve this answer
its leading to maddness alright! Thanks a lot I'll take a look at that, and try to master the command line. The consumer needs them in a format which apparently is strict about order of tags in <relation>, thanks again, Charlie – Charlie adams Feb 9 '11 at 16:52
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.