Jump to content

print html source code


torvald_helmer

Recommended Posts

Is there a way to print the html source code?

 

$file = file_get_contents("text.html");
print_r($file);

 

When I do this, it just shows the page as I would have seen it if I loaded the text.html in my browser.

 

What I want is to print the source code, as this:

<html>

<body>

texts and tags...

</body>

</html>

 

Is there a way to do this??

 

I want this because I am making a script that reads text in xhtml-format and sending the text to a database. Instead of having pages with unstructured xhtml, I want to have it all in a database, structured form. So I need to now the tags, so I can get the text-content out of the tags and send it to databases.

Link to comment
https://forums.phpfreaks.com/topic/47743-print-html-source-code/
Share on other sites

Thanks!

 

That worked like I wanted it.

 

While I am at it, do you have some tips about how to extract text?

 

In addition to html, head, body, meta-tags the html-file consist of a table,

and each of there rows (<tr>) have some text I want to extract.

 

E.g

 

<tr><td class="field">Lecturer</td><td>Professor Robert Langdon<br/></td></tr>

 

All rows has the same field class.

When I see the first <td>, here with 'lecturer', I want to to get the content of the second <td>.

The first td is the name of a coloum in my database, which will have the content of the second td.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.