|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 ![]() |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
Thanks.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Parsing HTML files in PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|