I've got some html in a string and I need to extract a table from it. So, for example, my htmlString variable contains (:
<html><head>....some head stuff</head><body><table>.... some table stuff</table>.... other body stuff</body></html>
So, what I have tried is the following: (typed, not copied, so there may be typos)
var table = $( '' ).append( htmlString ).find( 'table' ).get();
If I view my table variable, I do see:
[<table>...</table>]
so, I believe I am extracting the table from the html string correctly.
Now, to convert this back to a string, I do the following:
var tableString = $( table[0] ).html();
and I get back:
<tbody> ... the table stuff ... </tbody>
but, what I want is:
<table> ... the table stuff ... </table>
How can I do this?