Sign in Join

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

Mailing lists / lazarus / 2011-01

How to use GetElementById?

13 messages · 7 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110126/b7d671ec/attachment-0001.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: GetElementById_BUG.zip Type: application/zip Size: 7680 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110126/b7d671ec/attachment-0001.zip>

Reply by email

hector fiandor
to silvioprog

Hi guys

I have obtained the TDbf tutorial by Micha Nelissen (english version) and in the 6.35 Restructure Table it is mentioned the property Restruture, but I havent found.

I will appreciate any suggestion.

thanks in advance,

Ing. H?ctor F. Fiandor Rosario

Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistem a Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110126/4ccd8b1c/attachment.html>

Reply by email

Unknown author
to hector fiandor
hector fiandor wrote
Hi guys I have obtained the TDbf tutorial by Micha Nelissen (english version) and in the 6.35 Restructure Table it is mentioned the property Restruture, but I havent found.

The method is called RestructureTable. It needs a TDbfFieldDefs collection as the first argument. What is not clear ?

Michael.

Reply by email

Sergei Gorelkin
to silvioprog: I use the GetElementById in PHP with sucess, but in FPC I not know how use. In PHP I use…
silvioprog wrote
Hi guys, I use the GetElementById in PHP with sucess, but in FPC I not know how use.

(skipped)

GetElementById works by itself, but it requires a DTD to be present *and* it is able to resolve DTDs only at the filesystem level. Since your sample document contains DTD pointing to http://, it will be ignored, making your task difficult.
Also the parsing must be done in validating mode (see example 'Validating a document' at http://wiki.freepascal.org/XML_Tutorial)

Regards,
Sergei

Reply by email

hector fiandor
to Unknown author: The method is called RestructureTable. It needs a TDbfFieldDefs collection as the first…

Dear Mr. VanCanneyt:

Thanks for your answer.

In the TDbf tutorial by Micha Nelissen it is included an example.

If I prepare an utility application for "reestructure tables", maybe i can read the original table and the .mdx files, then introduce the new TDbfFieldDefs collection as the Nelissen'example, built and run, obtain new table and mdx files and copy to the original application. This is correct?

I have done something as described, but using others commands, and it looks rudimentary for me if we have a property/method for that.

Thanks and excuse me for the time consumption in this matter.

yours,

Ing. H?ctor F. Fiandor Rosario

Earlier message 28 lines
----- Original Message ----- From: To: "Lazarus mailing list" Sent: Thursday, January 27, 2011 3:21 AM Subject: Re: [Lazarus] about TDbf > > > On Wed, 26 Jan 2011, hector fiandor wrote: > >> Hi guys >> >> I have obtained the TDbf tutorial by Micha Nelissen (english version) and >> in the 6.35 Restructure Table it is mentioned the property Restruture, >> but I havent found. > > The method is called RestructureTable. It needs a TDbfFieldDefs collection > as the first argument. What is not clear ? > > Michael. -- Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/

Reply by email

Michael Van Canneyt
to hector fiandor
hector fiandor wrote 10 lines
Dear Mr. VanCanneyt: Thanks for your answer. In the TDbf tutorial by Micha Nelissen it is included an example. If I prepare an utility application for "reestructure tables", maybe i can read the original table and the .mdx files, then introduce the new TDbfFieldDefs collection as the Nelissen'example, built and run, obtain new table and mdx files and copy to the original application. This is correct?

Yes. I do not know if index files are corrected. It may be that indexes must be rebuilt.

I have done something as described, but using others commands, and it looks rudimentary for me if we have a property/method for that.

I am not sure I understand this remark. What could be more simple than the RestructureTable ?

Maybe it is possible to add something like

ResizeField(FieldName,NewSize)

and

RenameField(OldFieldName,NewfieldName)

These methods should be simple to implement.
But the advantage of the RestructureTable command is that it can do multiple .

Reply by email

hector fiandor
to Michael Van Canneyt

Dear Mr. VanCanneyt:

the matter is that i dont know that the reestructure method exists and during the designing period i need to add/change fields and sometimes add/change indexs

i designed an auxiliary program to do that, to mantain the information (dont lost it). Then re_reading the TDbf tutorial i "discover" the reestructue method and i try to find it in the submenu that appear when we write

<form1.TDbf.__________> but i dont see easyly

Now i will redesign the aux. app. with the Nelissen routine shown as example and see what happen.

In my previous design i include the previous and new FieldDefs and Index (althougt if dont change) and obtain new table and .mdx files with all the previous information and redesigned (fields and indexes).

Thanks very much again.

Ing. H?ctor F. Fiandor Rosario

Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/

Reply by email

hector fiandor
to Michael Van Canneyt: Yes. I do not know if index files are corrected. It may be that indexes must be rebuilt.…

Dear Mr. Michael Van Canneyt:

just now I have opened Lazarus and look again for the RestructureTable method, and I HAVE FOUND IT.

Please, I want you excuse me for this lag.

thanks again,

Ing. H?ctor F. Fiandor Rosario

Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/

Reply by email

silvioprog
to silvioprog: I use the GetElementById in PHP with sucess, but in FPC I not know how use. In PHP I use…

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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110130/3d059002/attachment.html>

Reply by email

Benito van der Zander
to silvioprog: Sorry... but nobody? :( 2011/1/26 silvioprog *Silvio Cl?cio* *Blog.*…

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:
"currency_converter_result"]/text()

If not, you can use my parser from
http://benibela.de/sources_en.html#internettools

Benito

silvioprog wrote 61 lines
Sorry... but nobody? :( 2011/1/26 silvioprog < <mailto:>> 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 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110130/561d85c2/attachment.html>

Reply by email

silvioprog

Oh, the email of
Sergei<http://lists.lazarus.freepascal.org/pipermail/lazarus/2011-January/059998.html>was in the spam page. Sorry Sergei. ^^'

Oops, I did not know about the crosspost, it will not happen again. ;)

Hm..., I did not understand much about how to use the GetElementById function, I'll avoid using this feature.

Thanks for the answers guys. :}D

2011/1/30 Andreas Schneider

Show quoted text 10 lines
On Sunday, January 30, 2011 13:52 silvioprog wrote: Sorry... but nobody? :( Well, when you crosspost to two mailing lists (which you shouldn't ...), then also check both of them ;-) There was an answer on the Lazarus ML. *-- Best Regards, Andreas*
*Silvio Cl?cio* *Blog.* blog.silvioprog.com.br *Twitter.* twitter.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110131/45a71be4/attachment.html>

Reply by email

silvioprog
to Benito van der Zander: i believe the DOM access methods are the most annoying thing ever, you can't just define…

Hi Benito,

Good parser. ;)

Instead of DOM, I could use GetPart, but I need something native with DOM. :/

Unfortunately I had to use a 'generic' option (...Item[NUMBER]...):

http://code.google.com/p/lazsolutions/source/browse/trunk/Demos/LSHTTPSend/MainFrm.pas#297

Anyway, thanks for the help. :)

2011/1/30 Benito van der Zander

Show quoted text 14 lines
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: "currency_converter_result"]/text() If not, you can use my parser from http://benibela.de/sources_en.html#internettools Benito
*Silvio Cl?cio* *Blog.* blog.silvioprog.com.br *Twitter.* twitter.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110131/bea16242/attachment-0001.html>

Reply by email