Question

[XML] order siblings

  • 16 May 2014
  • 1 reply
  • 3 views

Badge +1
Hi all,

 

 

I'm quite into FME+XML.

 

My today's question: How can I order the siblings of a node?

 

Example:

 

in:

 

<Book>

 

  <Format Type="Kindle">

 

    <Price>5.00</Price>

 

    <Currency>£</Currency>

 

    <AvailableDate>2010-05-01</AvailableDate>

 

  </Format>

 

  <Format Type="Paperback">

 

    <Price>8.00</Price>

 

    <Currency>£</Currency>

 

    <AvailableDate>2010-03-20</AvailableDate>

 

  </Format>

 

</Book>

 

 

out:

 

<Book>

 

  <Format Type="Kindle">

 

    <AvailableDate>2010-05-01</AvailableDate>

 

    <Price>5.00</Price>

 

    <Currency>£</Currency>

 

  </Format>

 

  <Format Type="Paperback">

 

    <AvailableDate>2010-03-20</AvailableDate>

 

    <Price>8.00</Price>

 

    <Currency>£</Currency>

 

  </Format>

 

</Book>

 

 

The node AvailableDate is now before Price.

 

Are the transformers XQueryUpdater or XMLUpdater right for that?

 

 

Regards,

 

-Maria

1 reply

Userlevel 4
Hi,

 

 

it's possible, but not super easy. I would try with a XMLFragmenter to convert the siblings into features, then send them through a Sorter and then an XMLTemplater to reassemble the XML.

 

 

David

Reply