Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-01

How to use GetElementById?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hi guys,

I use the GetElementById in PHP with sucess, but in FPC I not know how use.

In PHP I use (with sucess):

...
$dom = new DOMDocument();
  @$dom->loadHTML($data);
  $return = @$dom->getElementById('currency_converter_result')
    ->getElementsByTagName('span')->item(0)->firstChild->wholeText;
...

In FPC I try (but without sucess):

...
var
  VHTMLDocument: THTMLDocument = nil;
begin
  try
    ReadHTMLFile(VHTMLDocument, '../HTML/index.htm');
    ShowMessage(VHTMLDocument.GetElementById('currency_converter_result'
      ).GetElementsByTagName('span').Item[0].FirstChild.TextContent);
...

I found a 'generic' solution:

....

ShowMessage(VHTMLDocument.GetElementsByTagName('div').Item[5].TextContent);
// This is a unique alternative? :o
....

Any idea? The GetElementById function works? :/

Project to reproduce my problema in attached (with the HTML and PHP files).

( sorry for my bad english ^^' )

Thanks.

*Silvio Clécio* *Blog.* blog.silvioprog.com.br *Twitter.* twitter.com/silvioprog

Reply by email

silvioprog
to silvioprog

Sorry... but nobody? :(

2011/1/26 silvioprog

Show quoted text 41 lines
Hi guys, I use the GetElementById in PHP with sucess, but in FPC I not know how use. In PHP I use (with sucess): ... $dom = new DOMDocument(); @$dom->loadHTML($data); $return = @$dom->getElementById('currency_converter_result') ->getElementsByTagName('span')->item(0)->firstChild->wholeText; ... In FPC I try (but without sucess): ... var VHTMLDocument: THTMLDocument = nil; begin try ReadHTMLFile(VHTMLDocument, '../HTML/index.htm'); ShowMessage(VHTMLDocument.GetElementById('currency_converter_result' ).GetElementsByTagName('span').Item[0].FirstChild.TextContent); ... I found a 'generic' solution: .... ShowMessage(VHTMLDocument.GetElementsByTagName('div').Item[5].TextContent); // This is a unique alternative? :o .... Any idea? The GetElementById function works? :/ Project to reproduce my problema in attached (with the HTML and PHP files). ( sorry for my bad english ^^' ) Thanks.
*Silvio Clécio* *Blog.* blog.silvioprog.com.br *Twitter.* twitter.com/silvioprog

Reply by email