Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I have a large xml file which starts with <tele> and ends with </tele> in various occurrences. How can I cplit this file into small files.I need to split all between <tele> & </tele> into separate files.

Possibly a text editor than can search for the instances of <tele> and </tele>, then save each one off as file1.xml, file2.xml, etc. Then recombine as needed. Prolix seems to be a good choice (for a Windows enviroment). Possibly a Unix/Linux equivalent or run the 16-bit version under Wine...

Can I do it with a shell script? If so, how I will read the file?Since it is xml, my entire file looks to like single line.

The shell and common Unix tools work on line oriented text data. Since your data is all one large line, you will ultimately over flow the tool's buffer.
I am not familiar with XmlMax, but I think you will need something like that. You might search the web for other solutions.
If I were solving your problem, I'd create a "C" program that reads in a certain number of characters into a buffer, looks for your terminating characters, and then writes the data with the proper terminating character.

awk '/<tele/{close("row"count".xml");count++}count{f="row"count".xml";print $0 > f}' filename.xml
Worked for me

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |