Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6773821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:42:49+00:00 2026-05-26T15:42:49+00:00

I’m struggling with this for few hours, but I can’t get it to work

  • 0

I’m struggling with this for few hours, but I can’t get it to work properly. What I wanna do is find a line

<div id="content"> 

and add few lines below that contain some variables like

<div class="post">
    <h2 class="title"><a href="#">**var**</a></h2>
    <p class="meta"><span class="date">**var**</span>
    <span class="posted">Posted by <a href="#">**var**</a></span></p>
    <div style="clear: both;">
        &nbsp;
    </div>
    <div class="entry moreless">
        **var** 
    </div>
</div>

Is it possible? If so how?

–David

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:42:50+00:00Added an answer on May 26, 2026 at 3:42 pm

    There are much better tools available to solve this. But it is possible with Windows batch!

    Assume the text below is the outermost template file named TEMPLATE.HTML. The content trigger line can be indented, but this solution does not allow extra characters after the trigger. (This limitation could be solved, but it would slow things down)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title>Sample template for building a page</title>
      <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    </head>
    <body>
      <div id="content">
      </div>
    </body>
    </html>
    

    The sample content file below (named CONTENT_HTML.TXT) contains variables specified as !varName! and the batch file will use delayed expansion to perform the variable substitution. This means that if you want the content to contain an exclamation, it must be encoded somehow. There are two choices. One is to use the HTML character notation &#33; This works fine for text content, but will not work if you want an HTML comment. For comments I define an !X! variable that will be expanded to !

    <div class="post">
        <h2 class="title"><a href="#">!TITLE!</a></h2>
        <p class="meta"><span class="date">!DATE!</span>
        <span class="posted">Posted by <a href="#">!AUTHOR!</a></span></p>
        <div style="clear: both;">
            &nbsp;
        </div>
        <div class="entry moreless">
            Example with exclamation point&#33;<br />
            Another example with exclamation point!X!
        </div>
        <!X!--
          sample comment
        -->
    </div>
    

    Finally here is a batch file that will put everything together and create an output file named FINAL.HTML. I hard coded the values for the variables, but they could just as easily be passed in as arguments.

    @echo off
    setlocal enableDelayedExpansion
    set X=^^^!
    set TITLE=Sample HTML build
    set DATE=%date%
    set AUTHOR=Santa Clause
    set TEMPLATE="template.html"
    set CONTENT="content_html.txt"
    set FINAL="final.html"
    
    <%TEMPLATE% (
      for /f %%A in ('type %TEMPLATE%^|find /c /v ""') do (
          for /l %%N in (1 1 %%A) do (
          set "ln="
          set/p "ln="
          echo(!ln!
          set "test=!ln:*<=<!"
          if "!test!"=="<div id="content">" (
            for /f "usebackq delims=" %%L in (%CONTENT%) do echo(%%L
          )
        )
      )
    )>%FINAL%
    

    There are some limitations with this solution

    1. Empty lines (lines containing nothing but spaces) will be stripped from the Content portion. Probably not a problem with HTML. Eliminating this limitation will complicate and slow down the solution.
    2. Lines beginning with ; will be stripped from the Content portion. This limitation is easily removed, but the code is ugly looking. It involves specifying <LF> as the EOL character in the final FOR /F loop.
    3. The Template file must use the Windows newline standard of <CR><LF>. Unix style files using <LF> will fail with this solution. This also can be solved, but again it will complicate and slow things down.
    4. As I stated earlier, the content trigger in the Template can have leading spaces, but it cannot have any trailing characters on the line. Removing this limitation will slow the process down.
    5. Lines are limited to 1024 characters in Template
    6. Trailing control characters are stripped from each line in Template
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.