PDA

View Full Version : How to merge body text from various HTML pages


mvhall
07-24-2003, 05:46 AM
Hi all,
I am looking for some code to merge the text in the HTML body of various pages into 1 html page.
Has anyone got some ready to use PHP code?
Cheers,

Caimin
07-28-2003, 05:26 AM
Using include('filename.html'); would be a start - it depends exactly what you want to do...

mvhall
07-28-2003, 07:37 AM
Hi Caimin,
Yes I have posted this Q at phpbuilder and they came with the same solution, but unfortunately that is not an option for us as we have to deal with html pages made with a template and hence all contain header and footer rubbish.
So regEx would be the way forward.
Do you know any code to filter out the text between the body tags?
cheers,

Caimin
07-28-2003, 08:14 AM
I think what I'd do is:

Use include() to get the HTML

Put the HTML into a string

Use a PHP string function to search for the <body> tag.

Elminate everything before that <body> tag.

Do the same thing for the closing </body> - not that should be anything after the </body>, but you never know,

mvhall
07-28-2003, 09:17 AM
yep I agree that's the way to go.
When copied into a string I'll use regEx to filter out what I need.
Any idea how long the string may be to stick in a variable?

Cheers,

Caimin
07-28-2003, 10:24 AM
Depends on the length of the HTML page you're using...

mvhall
07-28-2003, 10:42 AM
I don't understand your reply :confused:
Why should it depend how long the string for a variable can be on the length of your HTML page?
http://nl3.php.net/manual/en/print/language.types.string.php
So looking at the definition for strings: it should not be a problem to copy the content of the whole html page into this string!?
cheers,

Caimin
07-28-2003, 12:24 PM
Shouldn't be a problem. From the manual:

Note: It is no problem for a string to become very large. There is no practical bound to the size of strings imposed by PHP, so there is no reason at all to worry about long strings.