zoozle Posted August 6, 2009 Share Posted August 6, 2009 Hi guys, i'm having some trouble stripping "div" tags from an xml document. I've tried using strip_tags, preg_replace and str_replace, they all work for removing the tags but the problem is i'm losing the contents within them as well. Then I tried just removing the opening or closing tag, not both, that worked but it's obviously not what I need. I have successfully done this with "p" tags with no problems, so im not sure what's happening. Any suggestions would be much appreciated. Thank you. Link to comment https://forums.phpfreaks.com/topic/169042-solved-stripping-div-tags-losing-its-contents/ Share on other sites More sharing options...
Mardoxx Posted August 6, 2009 Share Posted August 6, 2009 http://www.tek-tips.com/viewthread.cfm?qid=1231301&page=1 sources: I googled regex strip div tags also, guess which result it was... I'll give you a clue... It wasn't anything 2 or above. Link to comment https://forums.phpfreaks.com/topic/169042-solved-stripping-div-tags-losing-its-contents/#findComment-891901 Share on other sites More sharing options...
sasa Posted August 6, 2009 Share Posted August 6, 2009 try $text = preg_replace('#</?div[^>]*>#','',$text); Link to comment https://forums.phpfreaks.com/topic/169042-solved-stripping-div-tags-losing-its-contents/#findComment-891902 Share on other sites More sharing options...
zoozle Posted August 6, 2009 Author Share Posted August 6, 2009 Thanks alot guys, worked perfectly. Link to comment https://forums.phpfreaks.com/topic/169042-solved-stripping-div-tags-losing-its-contents/#findComment-891921 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.