PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 25th, 2004, 02:20 AM
ChrisIves ChrisIves is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 8 ChrisIves User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool Parsing HTML files in PHP

Hello all. I have used the search function and was unable to find anything that had a clear answer, so sorry if I overlooked something.

I am looking to get all the HTML tags into an array, or something similar. I need to be able to access their tag name (such as <a>, <table>, etc.) their attributes (href, etc.) and their containing text. This is all server-side on a PHP script.

I have seen use of preg_match, but I cannot figure out that command and the documentation skips over it's meaning from what I've seen. I would use XML but it seems that xml_parse skips tags that don't close themselves (such as <LINK> like most pages use to get style-sheets etc.)

Cheers for any examples

Reply With Quote
  #2  
Old March 25th, 2004, 07:49 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Do a search on "regular expressions" here and elsewhere. There has been a discussion recently on how to use preg_match to get tags. Preg_match() is basically an interface to the POSIX (I think) regular expression engine, which is what perl uses. Basically, you pass specially-formatted patterns and the text to search in to a function, which returns true on a match. You can use callbacks to process an array of matches. More than a tutorial on PHP functions, you'll need to find a tutorial on regular expressions; try some perl sites for starters.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old March 25th, 2004, 08:54 AM
ChrisIves ChrisIves is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 8 ChrisIves User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Parsing HTML files in PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway