Skip to Content
0
Former Member
Apr 18, 2008 at 09:50 AM

How can I Sort a Segment base on the value of one of the Elements

10 Views

Hi All,

I need to sort a segment base on a line number (one of the elements of the segment). The best way to explain my question is via the example below

For example:

Source

<Order>
	<Article>
		<LineNumber>3</ LineNumber>
                <ArticleCode>333123</ ArticleCode>
		<Description> Some sort of description</Description>
		…
	</Article>
	<Article>
		<LineNumber >1</LineNumber>
		<ArticleCode >111123</ArticleCode>
		<Description> another of description</Description>
		…
	</Article>
	<Article>
		<LineNumber >2</LineNumber>
		<ArticleCode >222123</ArticleCode>
		<Description> Again a description</Description>
		…
	</Article>

</Order>

Result should be:

Target

<Order>
	<Line>
		<LineNumber >1</LineNumber>
		<Article>
			<ArticleCode>111123</ArticleCode>
			<Description> another of description</Description>
		</Article>
		…
	</Line>
	<Line>
		<LineNumber >2</ LineNumber>
		<Article>
			<ArticleCode >222123</ArticleCode>
			<Description> Again a description</Description>
		</Article>
		…
	</Line>
        <Line>
		<LineNumber>3</ LineNumber >
                <Article>
                        <ArticleCode>333123</ArticleCode>
			<Description> Some sort of description</Description>
		</Article>
		…
	</Line>
</Order>

Thanks

Jacques