473,837 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regexp get data from html page

47 New Member
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 1624
gits
5,390 Recognized Expert Moderator Expert
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 New Member
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 Recognized Expert Moderator Expert
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 New Member
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 Recognized Expert Moderator Expert
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
39366
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: domything() And the regexp search assuming no case restriction would be,
5
2359
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. Or how can I replace the html &entities; in a string "blablabla&amp;blablabal&amp;balbalbal" with the chars they mean using re.sub? I found out they are stored in an dict . I though about this functionality:
3
4325
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 href="http://www.tempuri.org/page.html">http://www.tempuri.org/page.html</a> I have made the following code:
4
24781
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 how to use Regular Expressions?
0
1822
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 whatever I do gets errors. The examples use namespace regExp, but the supplied files use regexp, I've got it so that it at least doesn't complain about namespaces but it then complains that it can't find the match function. My stylesheet is:
6
2209
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 carriage return that was entered into the database was lost. I Created a function to replace a carriage return with a <BR>. I call this function when I display this data. If I enter text inside <> into a database and then display this data, any...
6
1419
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 working correctly: if( this.value != '' ) { if( !( RegExp( '^{0,200}$' ).test( this.value ))) { alert( 'Information provided must not be more than 200 characters.' ); this.focus(); } }
3
2028
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 electronic document and paste into form field which it will probably mess up the program. for example, we have a customer who wants to enter AH12345 into one of our fields, it appears АН12345 in hidden field of our asp page, but it displayed...
4
3914
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' is not an appropriate modifier for the test() function - test() searches the entire string by default. However, I would expect it to degrade gracefully. Instead, I seem to be getting something as follows - using W3Schools handy page at :
0
9843
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10577
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7811
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5670
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5851
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4476
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3126
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.