AnsweredAssumed Answered

Split XML based on Element value

Question asked by gasweet283435 on Jun 30, 2017
Latest reply on Jul 5, 2017 by krishna.mudunuri

I am trying to split XML documents based on an element, but keep documents together if the value in the element is the same.

Input:

<Document>
    <Header>
        <BOLNumber>1234</BOLNumber>
        <Detail>
            <Part>9867</Part>
        </Detail>
        <Detail>
            <Part>5897</Part>
        </Detail>
    </Header>
    <Header>
        <BOLNumber>1234</BOLNumber>
           <Detail>
               <Part>4567</Part>
           </Detail>
    </Header>
    <Header>
        <BOLNumber>9999</BOLNumber>
           <Detail>
               <Part>3234</Part>
           </Detail>
    </Header>
</Document>
I split based on the <BOLNumber> but if the value is the same I want the documents to stay together so the output
would look like this:

File 1:
<Document>
    <Header>
        <BOLNumber>1234</BOLNumber>
        <Detail>
            <Part>9867</Part>
        </Detail>
        <Detail>
            <Part>5897</Part>
        </Detail>
    </Header>
    <Header>
        <BOLNumber>1234</BOLNumber>
           <Detail>
               <Part>4567</Part>
           </Detail>
    </Header>
</Document>


File 2:
<Document>
    <Header>
        <BOLNumber>9999</BOLNumber>
           <Detail>
               <Part>3234</Part>
           </Detail>
    </Header>
</Document>

Outcomes