Jump to content

Must replace text, not tags, in Badly-formed HTML


alberto56

Recommended Posts

Hi all,

 

My input can be any html, badly-formed or otherwise, and I need to access and modify only the inner text parts of the dom without "correcting" the html. Here is an example of what I need:

 

Change: <div style="background-image:url(www.example.com/img.png)><p arg="www.example.com/img.png">You are viewing www.example.com/img.png</div></p>

 

to: <div style="background-image:url(www.example.com/img.png)><p arg="www.example.com/img.png">You are viewing <a href="http://www.example.com/img.png">www.example.com/img.png</a></div></p>

 

Notice that the closing </p> is not well placed. This is OK because I have another "filter" which corrects my html. This filter only needs to make links in the innerText without touching what are obviously tags.

 

I am having a hard time using the DOM System in PHP5 to do this...

 

Cheers,

 

Albert.

Hi, thanks, actually I am working on an open-source system, Drupal (http://drupal.org).

It is a CMS and provides functionality for filtering text. The way it works is that anyone can download it, and move the filters around as they see fit. Therefore, I cannot have one filter dependent on another. See also http://drupal.org/node/555280 which is the thread for the issue I am trying to solve.

 

Cheers,

 

A.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.