Computing.Net > Forums > Unix > Split large xml file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Split large xml file

Reply to Message Icon

Name: poornimajayan
Date: November 3, 2009 at 12:50:27 Pacific
OS: KSH
Product: Creative Vado pocket video cam pink camcorder
Subcategory: Software Problems
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: T-R-A
Date: November 3, 2009 at 13:17:46 Pacific
Reply:

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


0

Response Number 2
Name: poornimajayan
Date: November 3, 2009 at 13:25:48 Pacific
Reply:

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.


0

Response Number 3
Name: Billsahiker
Date: November 5, 2009 at 06:24:34 Pacific
Reply:

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


0

Response Number 4
Name: nails
Date: November 5, 2009 at 09:30:57 Pacific
Reply:

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.


0

Response Number 5
Name: poornimajayan
Date: November 9, 2009 at 15:38:57 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: barrier
Date: November 21, 2009 at 16:18:04 Pacific
Reply:

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

http://vtd-xml.sf.net


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Split large xml file

Viewing large log files www.computing.net/answers/unix/viewing-large-log-files/6329.html

Opening large log files in unix www.computing.net/answers/unix/opening-large-log-files-in-unix-/6035.html

Extract strings from big xml file www.computing.net/answers/unix/extract-strings-from-big-xml-file/7966.html