AnsweredAssumed Answered

How to Sort XML data along with Elements?

Question asked by iamshinde on Sep 1, 2017
Latest reply on Sep 1, 2017 by daniel.santana

How to Sort XML data along with Elements

 

We have below sample xml data and we would like to sort them base on ID Number element. 

 

<root>

   <OrderHeader>

      <OrderNumber> 123<OrderNumber>

      <Name>XYZ</Name>

      <Address>abc.xyz<Address>

   </OrderHeader>

   <OrderLine>

      <ID>1</ID>

      <qty>9999</qty>

   </OrderLine>

   <OrderLine>

      <ID>3</ID>

      <qty>79999</qty>

   </OrderLine>

   <OrderLine>

      <ID>4</ID>

      <qty>98999</qty>

    </OrderLine>

    <OrderLine>

      <ID>2</ID>

      <qty>99399</qty>

    </OrderLine>

   <OrderLine>

      <ID>3</ID>

      <qty>79990099</qty>

   </OrderLine>

</root>

 

===============================

Excepted Output:

==============================

<root>

   <OrderHeader>

      <OrderNumber> 123<OrderNumber>

      <Name>XYZ</Name>

      <Address>abc.xyz<Address>

   </OrderHeader>

   <OrderLine>

      <ID>1</ID>

      <qty>9999</qty>

   </OrderLine>

   <OrderLine>

      <ID>2</ID>

      <qty>99399</qty>

   </OrderLine>

   <OrderLine>

      <ID>3</ID>

      <qty>79999</qty>

   </OrderLine>

   <OrderLine>

      <ID>3</ID>

      <qty>79990099</qty>

   </OrderLine>

   <OrderLine>

      <ID>4</ID>

      <qty>98999</qty>

   </OrderLine>

 

</root>

Outcomes