Avatar of Vakils
VakilsFlag for United States of America asked on

Java: Split XML with multiple roots.

I need to split an xml file which has multiple roots into files having one root. How can I achieve this?

Avatar of undefined
Last Comment

8/22/2022 - Mon

Can you provide example of the file that you wish to process? Also, you mention Java in the title, is this what you are looking to implement a solution with? Can you provide some more info on the context of what you are trying to do? i.e. a web app, a console app, one off, etc? Also, is this part of a larger solution of just something standalone?

I do not have to use Java to split file, it can be any tool accessible in Windows, I do have C++. The xml parser is in java(web app), but it will not load because of multiple roots. So I have to split into multiple files based on each root. Then the parser can pick up the file and process. I cannot change parsing code, or the xml structure. I cannot ask vendor to give me multiple files, so I am stuck with splitting the file. Attached is an example with multiple roots. The  loader of portion of java web application picks up the file.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.