[Lazarus] How to use GetElementById?
Benito van der Zander
benito at benibela.de
Sun Jan 30 15:13:28 CET 2011
Hi,
i believe the DOM access methods are the most annoying thing ever, you
can't just define
a interface for all languages and expect it to be nice.
Doesn't the LCL contains an XPath-parser?
Then you could just use:
html//div[@id="currency_converter_result"]/text()
If not, you can use my parser from
http://benibela.de/sources_en.html#internettools
Benito
On 30.01.2011 13:52, silvioprog wrote:
> Sorry... but nobody? :(
>
> 2011/1/26 silvioprog <silvioprog at gmail.com <mailto:silvioprog at gmail.com>>
>
> 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 <http://blog.silvioprog.com.br>
> *Twitter.* twitter.com/silvioprog <http://twitter.com/silvioprog>
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110130/561d85c2/attachment-0003.html>
More information about the Lazarus
mailing list