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

  • SEARCH
  • Home
  • 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 9134889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:44:42+00:00 2026-06-17T08:44:42+00:00

How can I parse Name: & Value text from within the tag with DIHtmlParser?

  • 0

How can I parse Name: & Value text from within the tag with DIHtmlParser? I tried doing it with TCLHtmlParser from Clever Components but it failed. Second question is can DIHtmlParser parse individual tags for example loop through its sub tags. Its a total nightmare for such a simple problem.

<div class="tvRow tvFirst hasLabel tvFirst" title="example1">
  <label class="tvLabel">Name:</label>
  <span class="tvValue">Value</span>
<div class="clear"></div></div>

<div class="tvRow tvFirst hasLabel tvFirst" title="example2">
  <label class="tvLabel">Name:</label>
  <span class="tvValue">Value</span>
<div class="clear"></div></div>
  • 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-06-17T08:44:43+00:00Added an answer on June 17, 2026 at 8:44 am

    You could use IHTMLDocument2 DOM to parse whatever elements you need from the HTML:

    uses ActiveX, MSHTML;
    
    const
      HTML =
      '<div class="tvRow tvFirst hasLabel tvFirst" title="example1">' +
      '<label class="tvLabel">Name:</label>' +
      '<span class="tvValue">Value</span>' +
      '<div class="clear"></div>' +
      '</div>';
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      doc: OleVariant;
      el: OleVariant;
      i: Integer;
    begin
      doc := coHTMLDocument.Create as IHTMLDocument2;
      doc.write(HTML);
      doc.close;
      ShowMessage(doc.body.innerHTML);
      for i := 0 to doc.body.all.length - 1 do
      begin
        el := doc.body.all.item(i);
        if (el.tagName = 'LABEL') and (el.className = 'tvLabel') then
          ShowMessage(el.innerText);
        if (el.tagName = 'SPAN') and (el.className = 'tvValue') then
          ShowMessage(el.innerText);
      end;
    end;
    

    I wanted to mention another very nice HTML parser I found today: htmlp (Delphi Dom HTML Parser and Converter). It’s not as flexible as the IHTMLDocument2 obviously, but it’s very easy to work with, fast, free, and supports Unicode for older Delphi versions.

    Sample usage:

    uses HtmlParser, DomCore;
    
    function GetDocBody(HtmlDoc: TDocument): TElement;
    var
      i: integer;
      node: TNode;
    begin
      Result := nil;
      for i := 0 to HtmlDoc.documentElement.childNodes.length - 1 do
      begin
        node := HtmlDoc.documentElement.childNodes.item(i);
        if node.nodeName = 'body' then
        begin
          Result := node as TElement;
          Break;
        end;
      end;
    end;
    
    procedure THTMLForm.Button2Click(Sender: TObject);
    var
      HtmlParser: THtmlParser;
      HtmlDoc: TDocument;
      i: Integer;
      body, el: TElement;
      node: TNode;
    begin
      HtmlParser := THtmlParser.Create;
      try
        HtmlDoc := HtmlParser.parseString(HTML);
        try
          body := GetDocBody(HtmlDoc);
          if Assigned(body) then
            for i := 0 to body.childNodes.length - 1 do
            begin
              node := body.childNodes.item(i);
              if (node is TElement) then
              begin
                el := node as TElement;
                if (el.tagName = 'div') and (el.GetAttribute('class') = 'tvRow tvFirst hasLabel tvFirst') then
                begin
                  // iterate el.childNodes here...
                  ShowMessage(IntToStr(el.childNodes.length));
                end;
              end;
            end;
        finally
          HtmlDoc.Free;
        end;
      finally
        HtmlParser.Free
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I parse the html tables by giving only column name ? Like only
How i can parse and extract the parameters from an SQL Query using delphi?
Does a tool exist that can parse text and output that text, hyper-linked to
I want to parse the text line from the Wavefront OBJ file . Currently
I want to parse xml file from url : http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=cher&api_key=5d6ce941674603e4bb75cfad6cfa13b7 I want to parse
Is there a Python library that can parse an CSS selector and emit an
Does anybody know a Perl library that can parse XML documents and enables me
I need a PHP Regex that can parse .strings files. In particular, it needs
I'm using RSS library so i can parse Atom and RSS in Ruby and
I need a function that can parse both 1,123.12 and 1.123,12 to 1123.12 There

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.