How to Parse an HTML to Text

Hypertext Markup Language (HTML) is used to display and format Web pages. Parsing allows you to combine both HTML and text, so they appear as one entity. You can use JavaScript, a scripting language, to parse text and HTML on your Web page. JavaScript's document.write makes it possible to display HTML code and text within the script. For example, you can show the current date of your Web page, parse it with text, and use HTML to format the text on the page.

Instructions

    • 1

      Select "File" and "Open" from the toolbar of your preferred text editor, such as Notepad, TextPad or TextEdit. The "Open" dialog box appears.

    • 2

      Double-click the HTML file you want to parse.

    • 3

      Scroll to the section where you want the HTML code to display.

    • 4

      Add the following JavaScript code to parse HTML to simple text on a Web page:

      <html>

      <body>

      <script type="text/javascript"><!--

      document.write(<b>Hello World!!!</b>);

      //-->

      </script>

      </body>

      </html>

    • 5

      Add the following JavaScript code to display today's date, parse it with text and format it:

      <body>

      <script type="text/javascript"><!--

      var datenum = new Date();

      document.write("<i>Today is day </i>" + datenum.getDate() +"<i> !!</i><br /><b>It's finally here...</b>");

      //-->

      </script>

      </body>

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured