[SOLVED] Parsing HTML Documents

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

[SOLVED] Parsing HTML Documents

Post by timWebUK »

Hi everyone,

Currently I'm in the process of writing a script that grabs the contents of a HTML webpage and there's certain things I'd like to do with the contents, I just can't think of the most efficient way to do it.

Here's a list of things I'd like to do:

Modifying the contents of <img src> tags, modifying actual text (without effecting the text with <> tags), I thought of using preg_replace, but just can't think of how to create a regex to do it.

A simple example would be, the document contains:

<title>title</title>

And I want to modify the text 'title', without breaking the HTML text... any ideas?
Last edited by timWebUK on Wed Mar 10, 2010 7:55 am, edited 1 time in total.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Parsing HTML Documents

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: Parsing HTML Documents

Post by timWebUK »

Ah perfect, this should do fine. Thanks!
Post Reply