Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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