I am using an API to retrieve the HTML for all webforms inside of a certain application. The trouble is that the returned HTML contains <html>, <style>, and <body> tags around the <form>, but all I need is the <form> (there is also an onsubmit attribute, but I am fairly sure I can handle that a little bit down the road).
I was able to remove the style tags with some clever regex, but I am unsure of a way to remove the <form> from the middle of the <html> and <body> tags.
So far this is all happening in PHP. I am thinking it might be possible to json_encode the string and then pass it over to JS and use jQuery to getJSON maybe? I'm still not 100% clear on the best way to do this though.
Sample of my returned php string...
<html width="100%" height="100%">
<body class="body stuff">
<form>
<input type="text" name="input">
<input type="text" name="anotherInput">
</form>
</body>
</form>
All I want out of this string is the <form> though
DOMDocument?