Re: GetElementByClass?
| From: | vikash dot iitb at gmail dot com | Date: | Sat, 03 Apr 2010 15:21:44 +0000 |
| Subject: | Re: GetElementByClass? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-303774@lists.php.net to get a copy of this message | ||
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 <piero@the-admins.ch> wrote:
> 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:
> >
> > <p class="question">
> > Who is Roger Rabbit?
> > </p>
> >
> > 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.
> >
> > Now, I can extract each question by using javascript --
> >
> > document.getElementById("question").innerHTML;
> >
> > -- and stepping through each page, but I don't want to use javascript
> > for this.
> >
> > I have not found/created a working example of this using PHP. I tried
> > using PHP's getElementByID(), but that requires the target file to be
> > valid xml and the string to be contained within an ID and not a class.
> > These pages do not support either requirement.
> >
> > Additionally, I realize that I can load the files and parse out what
> > is between the <p> tags, but I was hoping for a "GetElementByClass"
> > way to do this.
> >
> > So, is there one?
> >
> > Thanks,
> >
> > tedd
>
> 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
>
>