Has anyone tried merging multiple HTML Files to single HTML File ?
am in confusion whether we need to treat HTML files as an ordinary text and and to append text or is there anyother way..
Printable View
Has anyone tried merging multiple HTML Files to single HTML File ?
am in confusion whether we need to treat HTML files as an ordinary text and and to append text or is there anyother way..
There is nothing magical or mysterious about HTML files... they are plain text. Ever open one up in Notepad?
As for appending... sure, you could just append to the end of the file... but you have to keep in mind the closing tags of one file and the opening tags of the other...
-tg
A html file consists of the following sections:
So, to merge two HTML files you have to actually merge their <BODY> sections, not whole files.HTML Code:<HTML>
<HEAD>
Header section
</HEAD>
<BODY>
Whatever you want - it's the body. Here is where actual contents go.
</BODY>
</HTML>
Everything that goes below </HTML> will be ignored by browser.
I need some fast approach to merge the contents because the number of HTML file count is morethan 1000 files..
- Open a source file 1 (File1)
- Grab everything between <BODY> ... </BODY> in the File 1 (data1)
- Open a source file 2 (File2)
- Grab everything between <BODY> .. </BODY> in the File 2 (data2)
- Open a target file
- Write to a target file either the header from File1 or File2 (depending on your needs) or write your own header
- Write the combined (data1 + data2) into the target file
- Close the target file with </BODY></HTML>