How to extract a HTML table from a string response in JavaScript?

I have been using a jira-client to create a jira utility and I need to extract data from tables in the description part. The response is in the form of string but inside the string the table is in the form of an html table

<p>Sample for jira utility tool</p>


<table border="0" cellpadding="0" cellspacing="0" class="jeditorTable" style="border-collapse:collapse; width:628pt">       
                <col style="width: 48pt;" width="64">
                <col style="width: 117pt;" width="156">
                <col style="width: 87pt;" width="116">
                <col style="width: 67pt;" width="89">
                <col style="width: 106pt;" width="142">
                <col span="2" style="width: 48pt;" width="64">
                <col style="width: 107pt;" width="143">
................(lot of data)

Since this is a string, how can I get this <table> to </table > data extracted to another string or some other form of data in JS ?

Why can’t you use the JIRA api to get the data you need?

This wrapper returns data as a string. My description includes tables so it returns table as an html table inside the string.

You will need to use an HTML parser. That is the best way outside of trying to hack some kind of regex to accomplish the task.

1 Like