ursvmg Posted June 6, 2010 Share Posted June 6, 2010 Hi, I have a very big html page, from which i need to remove data between specific tags. The edited html will then be used for parsing. Since the piece to be removed has unwanted(huge) data, which I don't want to be parsed. I did some google search, but I found none to be more effective. Most of them uses preg_replace. Is there any other way to do it? Could you please advice me on this. Regards, Ursvmg Quote Link to comment Share on other sites More sharing options...
GetPutDelete Posted June 6, 2010 Share Posted June 6, 2010 Can you post an example? Quote Link to comment Share on other sites More sharing options...
ursvmg Posted June 6, 2010 Author Share Posted June 6, 2010 . . <td> <form name="statuses" method=post><select name=status style="BACKGROUND-COLOR:#B3C7D7; font-family: verdana;font-weight:normal; font-size: 11px; color:black;" onChange="location=document.statuses.status.options[document.statuses.status.selectedIndex].value"> <option value="">[- Select Status -] <option value="">----------------- <option value="a.asp?status=On&state=&city=&category=R">On Schedule <option value="a.asp?status=PP&state=&city=&category=R">Postponed <option value="a.asp?status=C&state=&city=&category=R">Cancelled </select></td></form> <td> <form name="categories" method=post><select name=category style="BACKGROUND-COLOR:#B3C7D7; font-family: verdana;font-weight:normal; font-size: 11px; color:black;" onChange="location=document.categories.category.options[document.categories.category.selectedIndex].value"> <option value="R"> Real Estate <option value="">----------------- <option value="a.asp?category=R&state=&city=&status=">Real Estate <option value="a.asp?category=P&state=&city=&status=">Personal Property <option value="a.asp?category=O&state=&city=&status=">Other </select></td></form> </table> . . I would like to remove data between <form> tags. Quote Link to comment Share on other sites More sharing options...
GetPutDelete Posted June 6, 2010 Share Posted June 6, 2010 You could use str_replace to put markers in the code and then remove things between the markers, I did that once on a similar project when I didn't know what I was doing, turned out I could have done it 10 times quicker and easier with preg_replace. Quote Link to comment Share on other sites More sharing options...
haku Posted June 6, 2010 Share Posted June 6, 2010 If your form structure is valid, then you should be able to use this: preg_replace('/<form\b[^>]*>(.*?)<\/form>/', '', $data); Where $data is the HTML page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.