[PHP] GetElementByClass?

2010-04-03 Thread tedd
Hi gang: Here's the problem. I have 184 HTML pages in a directory and each page contain a question. The question is noted in the HTML DOM like so: Who is Roger Rabbit? My question is -- how can I extract the string "Who is Roger Rabbit?" from each page using php? You see, I want to stor

Re: [PHP] GetElementByClass?

2010-04-03 Thread Ashley Sheridan
On Sat, 2010-04-03 at 10:29 -0400, tedd wrote: > Hi gang: > > Here's the problem. > > I have 184 HTML pages in a directory and each page contain a > question. The question is noted in the HTML DOM like so: > > >Who is Roger Rabbit? > > > My question is -- how can I extract the string "W

Re: [PHP] GetElementByClass?

2010-04-03 Thread vikash . iitb
I use this: http://simplehtmldom.sourceforge.net/ Check it out. Thanks, Vikash Kumar -- http://vika.sh On Sat, Apr 3, 2010 at 8:28 PM, Ashley Sheridan wrote: > On Sat, 2010-04-03 at 10:29 -0400, tedd wrote: > > > Hi gang: > > > > Here's the problem. > > > > I have 184 HTML pages in a director

Re: [PHP] GetElementByClass?

2010-04-03 Thread Adam Richardson
> > > Who is Roger Rabbit? > > > My question is -- how can I extract the string "Who is Roger Rabbit?" from > each page using php? You see, I want to store the questions in a database > without having to re-type, or cut/paste, each one. > I have not found/created a working example of this usin

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
On Sat, 03 Apr 2010 08:58:44 -0600, Ashley Sheridan wrote: On Sat, 2010-04-03 at 10:29 -0400, tedd wrote: Hi gang: Here's the problem. I have 184 HTML pages in a directory and each page contain a question. The question is noted in the HTML DOM like so: Who is Roger Rabbit? My quest

Re: [PHP] GetElementByClass?

2010-04-03 Thread Ashley Sheridan
On Sat, 2010-04-03 at 08:11 -0600, Peter Pei wrote: > On Sat, 03 Apr 2010 08:58:44 -0600, Ashley Sheridan > wrote: > > > On Sat, 2010-04-03 at 10:29 -0400, tedd wrote: > > > >> Hi gang: > >> > >> Here's the problem. > >> > >> I have 184 HTML pages in a directory and each page contain a > >> qu

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
No javascript's getElementByID() won't work here. As "question" is a class, not an ID. But like what was mentioned here, you can use getElementByClass() with Opera, and that will work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] GetElementByClass?

2010-04-03 Thread dispy
Am 03.04.2010 16:29, schrieb tedd: > Hi gang: > > Here's the problem. > > I have 184 HTML pages in a directory and each page contain a question. > The question is noted in the HTML DOM like so: > > > Who is Roger Rabbit? > > > My question is -- how can I extract the string "Who is Roger Rab

Re: [PHP] GetElementByClass?

2010-04-03 Thread Piero Steinger
On 03.04.2010 16:29, tedd wrote: > Hi gang: > > Here's the problem. > > I have 184 HTML pages in a directory and each page contain a question. > The question is noted in the HTML DOM like so: > > > Who is Roger Rabbit? > > > My question is -- how can I extract the string "Who is Roger Rabbit?"

Re: [PHP] GetElementByClass?

2010-04-03 Thread vikash . iitb
If you are open to use javascript then a js library like jQuery may help in selecting all elements from a particular class. $(".clasName") Thanks, Vikash Kumar -- http://vika.sh On Sat, Apr 3, 2010 at 8:46 PM, Piero Steinger wrote: > On 03.04.2010 16:29, tedd wrote: > > Hi gang: > > > > Here

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
Yes, because Opera is pretty much leading the way with its HTML5 support. Not even Firefox supports as much as Opera does. Thanks, Ash http://www.ashleysheridan.co.uk Opera 10.10 is a very nice version, but 10.50 could be quite slow with some web pages. I still remember that once up

Re: [PHP] GetElementByClass?

2010-04-03 Thread Ashley Sheridan
On Sat, 2010-04-03 at 17:03 +0200, dispy wrote: > Am 03.04.2010 16:29, schrieb tedd: > > Hi gang: > > > > Here's the problem. > > > > I have 184 HTML pages in a directory and each page contain a question. > > The question is noted in the HTML DOM like so: > > > > > > Who is Roger Rabbit? > >

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
Why don't you just use REGEX? I don't know any possibility to easily process contents which are not valid XML/XHTML just because there's no library to load such stuff (but put me in right there). I'm not an expert of REGEX, but I think the following would do it: /\(.*)\<\/p\> (my first contr

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
Hi You could replace the "class" with "id" and then go on with JavaScript. A possible better way are regular expressions... Greetz Piero -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yes, and jquery is hosted on Microsoft CDN, do

Re: [PHP] GetElementByClass?

2010-04-03 Thread Ashley Sheridan
On Sat, 2010-04-03 at 08:22 -0600, Peter Pei wrote: > >> > > > > > > Yes, because Opera is pretty much leading the way with its HTML5 > > support. Not even Firefox supports as much as Opera does. > > > > Thanks, > > Ash > > http://www.ashleysheridan.co.uk > > > > > > Opera 10.10 is a very nice ve

Re: [PHP] GetElementByClass?

2010-04-03 Thread Ashley Sheridan
On Sat, 2010-04-03 at 20:51 +0530, vikash.i...@gmail.com wrote: > If you are open to use javascript then a js library like jQuery may help in > selecting all elements from a particular class. > > $(".clasName") > > > Thanks, > Vikash Kumar > -- > http://vika.sh > > > On Sat, Apr 3, 2010 at 8:

Re: [PHP] GetElementByClass?

2010-04-03 Thread Piero Steinger
On 03.04.2010 17:17, Ashley Sheridan wrote: > On Sat, 2010-04-03 at 17:03 +0200, dispy wrote: > > >> Am 03.04.2010 16:29, schrieb tedd: >> >>> Hi gang: >>> >>> Here's the problem. >>> >>> I have 184 HTML pages in a directory and each page contain a question. >>> The question is noted in the

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
I think Tedds main reason not to use Javascript is that he needs it to be done on the server rather than the client machine. ps. please use bottom posting on the list. Thanks, Ash http://www.ashleysheridan.co.uk But he also mentioned that he wanted to avoid copy and paste... it does gi

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
On Sat, 03 Apr 2010 09:21:17 -0600, Ashley Sheridan wrote: s, first browser to have tabs, first to have that odd homepage with thumbnails of y Talking about Opera's 'speed dial"... I downloaded safari yesterday (which I didn't like last time I used it), it now has the same kind of page bu

Re: [PHP] Re: array or list of objects of different types

2010-04-03 Thread Peter Pei
var_dump( array( true , 12 , "php already does this" ) ); array(3) { [0]=> bool(true) [1]=> int(12) [2]=> string(21) "php already does this" } :) Yeah. But this feature of PHP is a boon if used carefully and a curse if careless. You can get AMAZING results if you're not caref

Re: [PHP] GetElementByClass?

2010-04-03 Thread tedd
At 8:11 AM -0600 4/3/10, Peter Pei wrote: On Sat, 03 Apr 2010 08:58:44 -0600, Ashley Sheridan wrote: On Sat, 2010-04-03 at 10:29 -0400, tedd wrote: -snip- Now, I can extract each question by using javascript -- document.getElementById("question").innerHTML; Somejavascript engine alrea

Re: [PHP] GetElementByClass?

2010-04-03 Thread Nathan Nobbe
On Sat, Apr 3, 2010 at 8:29 AM, tedd wrote: > Hi gang: > > Here's the problem. > > I have 184 HTML pages in a directory and each page contain a question. The > question is noted in the HTML DOM like so: > > > Who is Roger Rabbit? > > > My question is -- how can I extract the string "Who is Rog

Re: [PHP] GetElementByClass?

2010-04-03 Thread tedd
At 3:58 PM +0100 4/3/10, Ashley Sheridan wrote: I don't think there is a getElementsByClass function. HTML5 is proposing one, but that will most likely be implemented in Javascript before PHP Dom. There is a way to tidy up the HTML to make it XHTML, but I'm not sure what it is. If you know roug

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
Somejavascript engine already support GetElementByClass, for example Opera does. My example shows how, namely: document.getElementById("question").innerHTML; will return the value within the class. Cheers, tedd In your original post, you said the data you had was: Who is Roger Rab

Re: [PHP] GetElementByClass?

2010-04-03 Thread tedd
At 8:14 AM -0600 4/3/10, Peter Pei wrote: No javascript's getElementByID() won't work here. As "question" is a class, not an ID. But like what was mentioned here, you can use getElementByClass() with Opera, and that will work. Sort of. Like I said, the folling will work: document.getElementB

Re: [PHP] GetElementByClass?

2010-04-03 Thread tedd
At 5:16 PM +0200 4/3/10, Piero Steinger wrote: Hi You could replace the "class" with "id" and then go on with JavaScript. A possible better way are regular expressions... Greetz Piero I can go with javascript "as-is" (what I showed) and don't have to change any html. Cheers, tedd -- --

Re: [PHP] GetElementByClass?

2010-04-03 Thread tedd
At 4:22 PM +0100 4/3/10, Ashley Sheridan wrote: I think Tedds main reason not to use Javascript is that he needs it to be done on the server rather than the client machine. ps. please use bottom posting on the list. Thanks, Ash Yeah, one reason was to get this done in one operation and no

Re: [PHP] GetElementByClass?

2010-04-03 Thread Nathan Nobbe
On Sat, Apr 3, 2010 at 10:18 AM, tedd wrote: > At 8:14 AM -0600 4/3/10, Peter Pei wrote: > >> No javascript's getElementByID() won't work here. As "question" is a >> class, not an ID. But like what was mentioned here, you can use >> getElementByClass() with Opera, and that will work. >> > > Sort

Re: [PHP] GetElementByClass?

2010-04-03 Thread tedd
At 9:14 AM -0600 4/3/10, Peter Pei wrote: Somejavascript engine already support GetElementByClass, for example Opera does. My example shows how, namely: document.getElementById("question").innerHTML; will return the value within the class. Cheers, tedd In your original post, you said the

Re: [PHP] GetElementByClass?

2010-04-03 Thread tedd
At 12:18 PM -0400 4/3/10, tedd wrote: At 8:14 AM -0600 4/3/10, Peter Pei wrote: No javascript's getElementByID() won't work here. As "question" is a class, not an ID. But like what was mentioned here, you can use getElementByClass() with Opera, and that will work. Sort of. Like I said, the f

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
Sort of. Like I said, the folling will work: document.getElementById("question").innerHTML; While you are using a getElementById, which returns an ID, but adding .innerHTML will return the class value. Try it. Cheers, tedd No, this will not work, if it appeared working, please re-chec

Re: [PHP] GetElementByClass?

2010-04-03 Thread tedd
At 10:03 AM -0600 4/3/10, Nathan Nobbe wrote: -snip- code Your code worked like a charm. Thanks. Now, I can extract each question by using javascript -- document.getElementById("question").innerHTML; tedd, are you slipping? i thought you were searching by the class attribute, lol. Yea

Re: [PHP] GetElementByClass?

2010-04-03 Thread Ashley Sheridan
On Sat, 2010-04-03 at 09:33 -0600, Peter Pei wrote: > > Sort of. > > > > Like I said, the folling will work: > > > > document.getElementById("question").innerHTML; > > > > While you are using a getElementById, which returns an ID, but adding > > .innerHTML will return the class value. > > > > Tr

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
It might have worked in Internet Explorer, as for a while that browser got confused over the class and id if two different elements on a page had the same class and id values. Thanks, Ash http://www.ashleysheridan.co.uk IE and Opera were the two I tested with. -- Using Opera's revolutionar

Re: [PHP] GetElementByClass?

2010-04-03 Thread Peter Pei
query("//p...@class='question']"); // here is where you extract the question sections of each file foreach($oNodeList as $oDomNode) var_dump($oDomNode->nodeValue); should be trivial to expand that to work w/ multiple files. Now, I can extract each question by using javascript -- document

[PHP] PHP (32 bit) on IIS7.5 and MySQL 5.1.45 (64 bit) -> established connection failed because connected host has failed to respond

2010-04-03 Thread Sumarliði Einar Daðason
Hi, I have recently upgrade to 64 bit Intel i7 computer running Windows 7 Ultimate 64 bit. I have setup PHP (32 bit) on IIS7.5 and MySQL 5.1.45 (64 bit) with success. phpinfo() shows the MySQL extension loaded, but when I try to use mysql_connect( $host, $user, $password ) in a PHP script I get f

[PHP] Collections / Static typing - was "array or list of objects of different types"

2010-04-03 Thread Nathan Rixham
Peter Pei wrote: > >>> >>> var_dump( array( true , 12 , "php already does this" ) ); >>> >>> array(3) { >>>[0]=> bool(true) >>>[1]=> int(12) >>>[2]=> string(21) "php already does this" >>> } >>> >>> :) >>> >> >> Yeah. But this feature of PHP is a boon if used carefully and a curse >

Re: [PHP] Collections / Static typing - was "array or list of objects of different types"

2010-04-03 Thread Peter Pei
On Sat, 03 Apr 2010 11:30:36 -0600, Nathan Rixham wrote: them in a google code project or suchlike. They'll obviously never be as fast as Java/C but they do allow for static typing of collections using primitive types That will be wonderful. -- Using Opera's revolutionary e-mail client: ht

Re: [PHP] PHP (32 bit) on IIS7.5 and MySQL 5.1.45 (64 bit) -> established connection failed because connected host has failed to respond

2010-04-03 Thread Kevin Kinsey
Sumarliði Einar Daðason wrote: I have setup PHP (32 bit) on IIS7.5 and MySQL 5.1.45 (64 bit) with success. phpinfo() shows the MySQL extension loaded, but when I try to use mysql_connect( $host, $user, $password ) in a PHP script I get following error: PHP Warning: mysql_connect() [function.m

[PHP] Re: Collections / Static typing - was "array or list of objects of different types"

2010-04-03 Thread Nilesh Govindarajan
On 04/03/10 23:00, Nathan Rixham wrote: Peter Pei wrote: var_dump( array( true , 12 , "php already does this" ) ); array(3) { [0]=> bool(true) [1]=> int(12) [2]=> string(21) "php already does this" } :) Yeah. But this feature of PHP is a boon if used carefully and a cur