I have the following XML stored in a String
<MessageHeader>
<MessageThreadId>201401140942060</MessageThreadId>
</MessageHeader>
<MessageNotificationPeriod>
<StartDate>2013-11-01T00:00:00.000000</StartDate>
<EndDate>2013-12-01T00:00:00.000000</EndDate>
</MessageNotificationPeriod>
<SalesReport>
<SalesByTerritory>
<TerritoryCode>US</TerritoryCode>
</SalesByTerritory>
</SalesByCommercialModel>
</SalesReport>
I want to split the string into 3 parts so that it can be printed at different places in the file I will be creating. I want </MessageNotificationPeriod>
to end the first part, </TerritoryCode>
to end the second part and the remaining to be in the third new string. I've tried to use String.split() but it removes the string I am splitting at.