• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 133
  • Last Modified:

Including text from a file to HTML file

Hi Experts,

Is there a way to display the contents of another text file.  For example,

<html><head><title></tille></head>

<body>

Some text from another text file....
</body>
</html>

I was thinking of doing this way, so that the article I want to include be in some text file and I don't have to change any of the html files for it.
0
ambuli
Asked:
ambuli
  • 2
  • 2
  • 2
  • +1
1 Solution
 
JoeCommented:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<div>
<p>this is where you would copy the text</p>
</div>
</body>
</html>

Regards,

JoeZ430
0
 
gjutrasCommented:
what web server? IIS, apache  (version?)
What you want can probably be done with includes if they're turned on on your web site.
0
 
ambuliAuthor Commented:
Hi, my web server is apache.  I am not sure if include is turned on there and is it something turned off usually?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ambuliAuthor Commented:
and could you show me an example of this?  Thanks,
0
 
JoeCommented:
You would have to use server side code. ASP, PHP, JSP etc..
0
 
b0lsc0ttCommented:
The simplest method is to use an iframe.  For example ...

<html><head><title></title></head>

<body>

<iframe src="filename.txt" width="200" height="200"></iframe>
</body>
</html>

Since you are using Apache you probably can use PHP (mentioned above).  It is a server side language and it could read the other file and insert the contents in the html page.  It would actually write the HTML too.  For example you can make a file called file.php and put the code below in it.

<html><head><title></tilte></head>

<body>

<?php
include 'filename.txt';
?>
</body>
</html>

When this file was run in the browser you would see the html and the contents of the other file.  Another option on Apache, but often disabled, is SSI (server side includes).  If it is enabled then you would use code like the one below and need to end this filename with .shtml.

<html><head><title></title></head>

<body>

<!--#include file="filename.txt" -->
</body>
</html>

Let me know how this helps or what additional info you need.

bol
0
 
b0lsc0ttCommented:
I'm glad I could help.  Thanks for the grade, the points and the fun question.

bol
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now