Writing an HTML Preprocessor

This is a discussion on Writing an HTML Preprocessor within the C++ Programming forums, part of the General Programming Boards category; I'm trying to write an HTML preprocessor. What is the best way to go about this? Should I read the ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    196

    Writing an HTML Preprocessor

    I'm trying to write an HTML preprocessor. What is the best way to go about this? Should I read the entire file into a character array first, and then process that? Should I read it into an array of strings instead?

    Basically I have an HTML file, like the one below.

    Code:
    <html>
    <title></title>
    <body>
    
    <h1>This is an HTML file.</h1> 
    
    #insert HelloWorld.html                 
    
    </body>
    </html>
    When I run the preprocessor on the above HTML code, the line that reads "#insert HelloWorld.html" is replaced by the contents of the file "HelloWorld.html."

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Depends on how complex your transformation is. If it's just preprocessor-like directives, streaming the file through a filter is sufficient, and much more memory-efficient than reading it whole.
    XSLT, on the other hand, is so complex that it must parse both the style sheet and the file it works on in full before being able to do anything.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help - C code creates dynamic HTML
    By Christie2008 in forum C Programming
    Replies: 19
    Last Post: 04-02-2008, 07:36 PM
  2. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  3. Preprocessor Directives Problem
    By MipZhaP in forum C++ Programming
    Replies: 6
    Last Post: 02-18-2005, 12:53 PM
  4. help! fifo read problem
    By judoman in forum C Programming
    Replies: 1
    Last Post: 08-16-2004, 09:19 AM
  5. html form - writing ip to a hidden field
    By iain in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 11-16-2001, 02:29 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21