splitting huge xml into multiple files

hi all
i have a some huge html files (500MB to 1GB). Each file has multiple
<html></html> tags

<html>
.................
....................
....................
</html>
<html>
.................
....................
....................
</html>
<html>
.................
....................
....................
</html>
..........
..........

I want to split these html files into smaller files with <html> in the beginning and </html> at the end

<html>
.......
.......
</html>
<html>
..........
..........
</html>

Kindly suggest me a perl/awk/sed or any shell script solution.

Thanks and Regards,
uttam hoode

Something like this?

awk '/<html>/{c++}c>2{exit}1'  file

Regards

hi franklin,
how can i create multiple file from a huge html file?

i tried this

awk '/<html>/{n++}{print >"output" n ".html" }' input.html

but splitting is not proper. one file should contain many <html> </html> sets

Thanks and Regards,
uttam

Try this:

awk '
/<html>/{close("file"c".html");c++}
{print $0 > "file"c".html"}
' file

Regards

hi franklin,
its is creating one file for <html> </html>. how can i create one file for more than one set of <html> </html>?

eg

file.1.html
<html>
....
....
</html>
<html>
....
....
</html>
<html>
....
....
</html>

file2.html
<html>
....
....
</html>
<html>
....
....
</html>
<html>
....
....
</html>

file3.html
<html>
....
....
</html>
<html>
....
....
</html>
<html>
....
....
</html>

so on...

last file will contain remaining <html>...</html> s

Thanks and Regards,
uttam hoode

awk 'BEGIN{c=1}
/<html>/{n++}
n==4{n=1;c++;close("file"c".html")}
{print $0 > "file"c".html"}
' file

Regards