473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Regexp get data from html page

47
Hey

I have to get some data from a html page into an other page. I know how to get the data by a simple AJAX request, but I don't know to find the data.

The data i need to find is in a table, and there are about 100 rows in it. I only need to get one. The only thing i got is the persons ID.
The row looks like this:
[HTML]
<tr class="Lyscell">
<td>48</td>
<td>29</td>
<td>Persons name</td>
<td>Persons ID</td>
</tr>
[/HTML]


I was thinking of a regexp or something, but i'm open for all other ways to find the data in the html page :)
Apr 19 '08 #1
5 1599
gits
5,390 Expert Mod 4TB
hmmm ... i'm not quite sure what you mean? basicly you want to retrieve the last cell in every row and get its text that is a person's ID? am I right?

kind regards
Apr 19 '08 #2
Andelys
47
No, that not what i want. Sorry for the bad explanation.'

I have the person id, and i want the get the whole row that its in.

Fx i have the person id: 123 and the table looks like this:
[HTML]
<table>
<tr>
<td>115</td>
<td>153</td>
<td>persons name</td>
<td>persons ID</td>
</tr>
<tr>
<td>1135</td>
<td>133</td>
<td>persons name</td>
<td>123</td>
</tr>
<tr>
<td>23423</td>
<td>133</td>
<td>persons name</td>
<td>persons ID</td>
</tr>
</table>
[/HTML]

How do i get that row?
Apr 19 '08 #3
gits
5,390 Expert Mod 4TB
i see ... could there be more then one row with that person id? are you using responseText or responseXML? do you need to display the entire table or just need the retrieved row from the response?

kind regards
Apr 19 '08 #4
Andelys
47
No only one person have that id.
I'm using reponseText.
I just need to get that one row were the ID is in. If it helps, i can also use the name for finding the row.
Apr 19 '08 #5
gits
5,390 Expert Mod 4TB
hmmm ... may be the following example helps:

Expand|Select|Wrap|Line Numbers
  1. var s = '</tr><tr><td>1135</td><td>133</td><td>persons name</td><td>123</td></tr><tr><td>23423</td>';
  2.  
  3. var id = '123';
  4. var re = new RegExp('.+' + id + '</td></tr>');
  5.  
  6. var row = s.match(re)[0].match(/<tr>.+$/)[0];
  7.  
  8. alert(row);
but the best way would be to just retrieve the needed data from the database ... instead of the entire table ... or is this not an option?

kind regards
Apr 22 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1:...
5
by: Lukas Holcik | last post by:
Hi everyone! How can I simply search text for regexps (lets say <a href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a dictionary { name : URL}? In a single pass if it could....
3
by: Jesper Stocholm | last post by:
I need to be able to detect URIs in some text and after this replace dem with HTML-anchors, that is http://www.tempuri.org/page.html should be replaced with <a...
4
by: McKirahan | last post by:
How would I use a regular expression to remove all trailing Carriage Returns and Line Feeds (%0D%0A) from a textarea's value? Thanks in advance. Also, are they any great references for learning...
0
by: Chris Croughton | last post by:
I'm trying to use the EXSLT regexp package from http://www.exslt.org/regexp/functions/match/index.html (specifically the match function) with the libxml xltproc (which supports EXSLT), but...
6
by: Matt | last post by:
Premise: Inserting data into a database form a <textarea> and displaying this data through an HTML page. When inserting data into a database via a text area and then displaying this data any...
6
by: Christoph | last post by:
I'm trying to set up client side validation for a textarea form element to ensure that the data entered does not exceed 200 characters. I'm using the following code but it doesn't seem to be...
3
by: c676228 | last post by:
Hi everyone, I just realized that it's so important to validate each string, I mean 'each' before you insert data from asp page into database. I guess some customers just copy data from some...
4
by: Matt | last post by:
Hello all, I have just discovered (the long way) that using a RegExp object with the 'global' flag set produces inconsistent results when its test() method is executed. I realize that 'global'...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.