473,396 Members | 2,093 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,396 software developers and data experts.

HTML table parsing, capturing with back referencing problem.

Hi,

Task :
-Capture a HTML table with use of regular expression from a text string buffer(entire document).
–Pass it to another function to create a multi dimension array out of it.
- Pass it to another function to build it into a RTF table.
-Then return it back to the regular expression to replace the search result.

Difficulty:
-The regular expression doesn’t pass the back referenced table fields to the next function.

What I am trying to do is extremely confusing for my level of experience.
How can I pass the relevant data to and from the regular expression?


Regular Expression for capturing the Table from the buffer.[PHP]
if(preg_match("/<table>(.*?)<\/table>/mi", $doc_buffer))
{
$start_delim = "<table>";
//$end_delim = "<\/table>";
$end_delim = "<#table>";
$content = preg_replace("/(.*)".preg_quote($start_delim)."(.*)".preg_quote($ end_delim)."(.*)/si", $this->buildTable("\\2"),$doc_buffer);
echo $content;
}[/PHP]


Table to RTF Processing
[PHP]function shapeTable($array)
{
$head = '\\par \n\\qc\n';
$row1 = '\\trowd \\trautofit1 \n\\intbl\n';
$row2 = '\\row} \n';
$tail = '\\pard}\n';
$colInfo = '';
$output = '';
$cell = '\\cell ';
//create column details

$i=0;
$colL = $array.count();
$rowL = $array[0].count();

for($i = 0; $i < $rowL; $i++)
{
$colInfo .= '\\cellx'.($i + 1 ).' \n';
}
//add together strings
$output .= $head;
for($i = 0; $i < $colL; $i++)
{
$output .= $row1.colInfo.'{';
for($j = 0; $j<$rowL; $j++)
{
$output .= $array[$i][$j].$cell;
}
$output .= '}{' . row1 . colInfo.$row2;
}
$output.=$tail;
return $output;
}[/PHP]
Apr 10 '07 #1
0 1589

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

Similar topics

7
by: Sugapablo | last post by:
Before I go building this, I want to know if it already exists. I need some PHP code that will read a web page and return all text that comes between <td></td> tags in an array. So if there...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
22
by: Anoop Ghanwani | last post by:
In my public_html directory, I have a bunch of files: index.html x.html, y.html, etc. When a user accesses the domain without a file name, he/she automatically accesses the index.html file....
5
by: jwang | last post by:
I'm currently writing some C code that uses libxml. I've seen several example of parsing xml when the xml are in files. However, I would like to parse the xml from a char buffer. Currently I am ...
59
by: Lennart Björk | last post by:
Hi All, I have a tiny program: <!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>MyTitle</title> <meta...
2
by: coolnoff | last post by:
I have a dts which creates a table which is utilized on my local intranet. The DTS runs without error and the table is created/populated/transfered to the appropriate db. Then it appears that...
9
by: anupamjain | last post by:
Hi, After 2 weeks of search/hit-and-trial I finally thought to revert to the group to find solution to my problem.(something I should have done much earlier) This is the deal : On a JSP...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
7
by: SteveM | last post by:
I am sure this is an easy question, but being relatively new to ASP.NET programming, I can not quite grasp what I need to accomplish what I need to do. What I have is a word document that is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.