alberto56 Posted September 3, 2009 Share Posted September 3, 2009 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. Link to comment https://forums.phpfreaks.com/topic/173021-must-replace-text-not-tags-in-badly-formed-html/ Share on other sites More sharing options...
bundyxc Posted September 3, 2009 Share Posted September 3, 2009 You might try your first 'filter' first, so that you don't have such badly-formed HTML, you know? Link to comment https://forums.phpfreaks.com/topic/173021-must-replace-text-not-tags-in-badly-formed-html/#findComment-911932 Share on other sites More sharing options...
alberto56 Posted September 3, 2009 Author Share Posted September 3, 2009 Thanks for the reply. However, I cannot control the order in which users apply filters, or whether they are applied at all. Link to comment https://forums.phpfreaks.com/topic/173021-must-replace-text-not-tags-in-badly-formed-html/#findComment-911944 Share on other sites More sharing options...
bundyxc Posted September 4, 2009 Share Posted September 4, 2009 ...I don't understand why not. It's completely your program, right? Link to comment https://forums.phpfreaks.com/topic/173021-must-replace-text-not-tags-in-badly-formed-html/#findComment-912661 Share on other sites More sharing options...
alberto56 Posted September 5, 2009 Author Share Posted September 5, 2009 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. Link to comment https://forums.phpfreaks.com/topic/173021-must-replace-text-not-tags-in-badly-formed-html/#findComment-912994 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.