Split Xml by lines

NosokOrg

Power Member
Joined
Jun 21, 2015
Messages
506
Reaction score
21
Hello to all. I have a regular task to split large xml files ( for example 580k lines ) to little files by 10k lines in each? Is any some script or solution to make it automatically ?
 
If it was plain text, sure - but xml has structure, it's not just standalone lines.
 
EmEditor works fine in windows. Not automatically, but dont suspend in case to open large file.
 
It's as Jazzc says, there's no reason to split XML up into seperate lines, as it's not a line-by-line format, however if you still want to do this you can write a simple application to do so, take a look at the BufferedReader and BufferedWriter classes in Java. You can write an application with minimal programming knowledge to do this in around ten minutes.
 
Depends the structure of your file and why do you want to split it for.
If you have a main root tag and then a bunch of subitem, you probably want to recreate the root tag in each splitted file.
You should start by finding an xml library for the language you're using, then read the file into some kind of array, from here you'll be able to split easily, then write it back using that same library.
 
as far as I know - no, you can't do that.

but, is there a chance the size is that huge as you don't use css?
 
OP, can you post an example of what exactly you would like to achieve ? If so, maybe I will be able to help you.
 
Why would you want to do that? Obviously you're going to have to process the file, and what if one chunk only has half of a node? Bam. Invalid XML and you won't be able to read it. Grab the entire file and use an efficient parser. There's one for every programming language.
 
Back
Top