Search code examples
htmlwebauto-generate

How to auto generate HTML page from a text file?


I have a text file named info.txt and I want to generate a HTML page that shows its contents. How can I achieve it?

Text file:

Year : 2012
Name : Dragons
Size : 250mb

Expected HTML output:

Year of Realese : 2012
Name of the Show : Dragons
Size : 250

Solution

  • You have a key:value pair, you can save it as a json file use xmlhttpresponse to read json and create html elements. But xmlhttpresponse requires you to have a server running, it won't work locally. Read about json and how to access them using Javascript. It's very simple.