473,322 Members | 1,734 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,322 software developers and data experts.

Parsing html to php array

I've been trying to find a code or a way to create that

a parse that return this to me:

$html['body']['p'] = 'loren ipsum';
$html['body']['p'] = 'loren ipsum 2';
$html['body']['p']['a'] = 'path/to/a/file';
$html['body']['table']['tr'][0]['th'] = 'header 1';
$html['body']['table']['tr'][0]['th'] = 'header 2';
$html['body']['table']['tr'][0]['th'] = 'header 3';
$html['body']['table']['tr'][1]['td'] = 'column 1';
$html['body']['table']['tr'][2]['td'] = 'column 2';
$html['body']['table']['tr'][3]['td'] = 'column 3';
etc.
thanks for any answer
Feijó
Jul 4 '08 #1
3 4445
If your input is properly generated XHTML, try out simplexml. If not, pipe
the HTML through tidy to get celan XHTML, then pipe it to simplexml.

--
----------------------------------
Iván Sánchez Ortega -ivan-algarroba-sanchezortega-punto-es-

Now listening to: Fatboy Slim - The Best of Classic Chillout: Sunrise
(2002) - [4] Praise You (full version) (5:21) (96.285698%)
Jul 4 '08 #2
NC
On Jul 4, 6:18 am, Feijó <afe...@gmail.comwrote:
>
I've been trying to find a code or a way to create that
a parse that return this to me:

$html['body']['p'] = 'loren ipsum';
$html['body']['p'] = 'loren ipsum 2';
Um, the first line would create an element in the array, the second
line would overwrite that element with a new value. So your approach
to parsing seems to be flawed...

Cheers,
NC
Jul 4 '08 #3
It was just a example I wrote to better explain, I just forget to add
[] at the end on both lines :)
On Jul 4, 4:53*pm, NC <n...@iname.comwrote:
On Jul 4, 6:18 am, Feijó <afe...@gmail.comwrote:
I've been trying to find a code or a way to create that
a parse that return this to me:
$html['body']['p'] = 'loren ipsum';
$html['body']['p'] = 'loren ipsum 2';

Um, the first line would create an element in the array, the second
line would overwrite that element with a new value. *So your approach
to parsing seems to be flawed...

Cheers,
NC
Jul 7 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: YoBro | last post by:
Hi I have used some of this code from the PHP manual, but I am bloody hopeless with regular expressions. Was hoping somebody could offer a hand. The output of this will put the name of a form...
4
by: ralphNOSPAM | last post by:
Is there a function or otherwise some way to pull out the target text within an XML tag? For example, in the XML tag below, I want to pull out 'CALIFORNIA'. ...
3
by: djdave | last post by:
My problem is that i need an algorithm parse parse HTML. For an HTML page, my script has to parse all tags to get all forms values, even if there is frame, iframe, ... How can i do such a script ?...
4
by: Brett | last post by:
Are there any good HTML parsing tools available for VB.NET? I'd like something that will list: - tables (table, tr, td) - anchor tags - image tabs - DIVs and so. For example, it may list...
11
by: Ørjan Langbakk | last post by:
I'm parsing a CSV-file into a table on a webpage - and I'd like to be able to change the alignment for the _last_ <td> in each <tr> - but, as the file is today, it's not possible for me to assign a...
1
by: prakash280681 | last post by:
how to get the correct result when we parse the xml code.Because in parsing when it get the syntax like < and & it break it and forward.. i use the code---- <?php $xml_file = "news.xml"; ...
2
by: blitzztriger | last post by:
Hello!! how do i insert values into mysql , after parsing a submiting textbox?? I made the arrays, so this should be a basic insertion of them in the db, but something is missing, or in the wrong...
1
by: bruce | last post by:
Hi Paul... Thanks for the reply. Came to the same conclusion a few minutes before I saw your email. Another question: tr=d.xpath(foo) gets me an array of nodes.
1
by: Philip Semanchuk | last post by:
On Oct 12, 2008, at 5:25 AM, S.Selvam Siva wrote: Selvam, You can try to find them yourself using string parsing, but that's difficult. The closer you want to get to "perfect" at finding URLs...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
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

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.