I need to remove some specific tag from HTML example.
To avoid using iframe, I am getting an HTML page in my PHP file using curl
and using getJSON. I am getting the result in my.js,
but I am not taking the whole HTML and pasting it in my own div.
I guess the reason for this is that I can not have more than one HTML, HEAD, and BODY tag in one HTML structure.
<!DOCTYPE html>
<html>
<head>
<style>some style</style>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
Now in the above structure I do not need HTML, BODY, and HEAD tags, but I do need a STYLE tag for CSS so I just want to remove HTML, BODY, and HEAD tags.
After removing I need to append this to my div (all this trouble is because I do not want to use iframes).
How do I remove it? I thought of strip_tags()
and preg_replace
or some regex function, but couldn't understand the best way to do it.
Please help me find the best way to do this.
It could be in PHP, JavaScript, or JQuery.
but i would appriciate if answer are in javascript and jquery since i would like to do this manupulation in my JS but if needed PHP will also work
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…