Split large xml file

Score
0
Vote Up
November 3, 2009 at 12:50:27 Pacific
Specs: KSH

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.

Reply ↓  Report •


#1
Vote Down
Score
0
Vote Up
November 3, 2009 at 13:17:46 Pacific

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...

Reply ↓  Report •

#2
Vote Down
Score
2
Vote Up
November 3, 2009 at 13:25:48 Pacific

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.

Reply ↓  Report •

#3
Vote Down
Score
0
Vote Up
November 5, 2009 at 06:24:34 Pacific

XmlMax will do this easily. Just get the free 30 day trial from xponentsoftware

Reply ↓  Report •

#4
Vote Down
Score
0
Vote Up
November 5, 2009 at 09:30:57 Pacific

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.


Reply ↓  Report •

Related Posts

#5
Vote Down
Score
8
Vote Up
November 9, 2009 at 15:38:57 Pacific

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

Reply ↓  Report •

#6
Vote Down
Score
0
Vote Up
November 21, 2009 at 16:18:04 Pacific

You might want to look at vtd-xml, which is ideally suited for splitting xml

http://vtd-xml.sf.net


Reply ↓  Report •

Reply to Message Icon Start New Discussion
« Run Unix command in DOS F... Search and replace »

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.

Ask the Community!
Describe your Problem
Example: Hard Drive Not Detected on My PC