Link to home
Start Free TrialLog in
Avatar of Sridhar Lenkala
Sridhar Lenkala

asked on

HTML to CSV using xslt

Hi all,

I need an xslt to convert HTML to CSV. I know there are other ways to convert but I have a process which only accept xslt to convert HTML to CSV.
I am attaching source HTML file and csv file i want, can some one please create xslt for me. Appreciate any help on this since this is an urgent requirement and i am new to xslt.

Essentially below file lines of the csv files are 1 on 1. and you can get them in the body part pasted below.

Total Transactions:,245
Successful Transactions:,243
Failed Transactions:,2
Duplicate Transactions:,0
Unprocessed Transactions:,0
Transaction,Error Message,Details

 <body>
        <div class="container-fluid">
          <h4>Upload Summary</h4>
          <div class="row">
            <div class="col-md-4">
              <table class="table table-bordered table-striped table-condensed">
                <tr>
                  <td>
                    <b>Total Transactions:</b>
                  </td>
                  <td align="right">245</td>
                </tr>
                <tr>
                  <td colspan="2">
                    <hr/>
                  </td>
                </tr>
                <tr>
                  <td align="right">
                    <b>Successful Transactions:</b>
                  </td>
                  <td align="right">243</td>
                </tr>
                <tr>
                  <td align="right">
                    <b>Failed Transactions:</b>
                  </td>
                  <td align="right">2</td>
                </tr>
                <tr>
                  <td align="right">
                    <b>Duplicate Transactions:</b>
                  </td>
                  <td align="right">0</td>
                </tr>
                <tr>
                  <td align="right">
                    <b>Unprocessed Transactions:</b>
                  </td>
                  <td align="right">0</td>
                </tr>
              </table>
            </div>
          </div>
          <hr/>
          <h5>Error Summary</h5>
          <div class="row">
            <div class="col-md-12">
              <table class="table table-bordered table-striped table-condensed tablesorter">
                    <thead>
                     <tr>
                       <th class="col-md-1" align="center">Transaction</th>
                       <th class="col-md-10">Error Message</th>
                       <th class="col-md-1" align="center">Details</th>
                     </tr>
                  </thead>
                  <tbody>
FailureReport--19-.html
convertcsv.csv
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Keep in mind, your HTML will likely have to be well formed to use XSLT.

If your HTML is poorly formed (HTML syntax errors), use one of the many html2csv convertors available.
@david
good point
note however that the poster of this question is using a tool that offers XSLT as its only means for processing the html
a process which only accept xslt to convert HTML to CSV
I have tested the XSLT I posted on the source HTML sent, and it is wellformed
(it is referencing the XHTML DTD and it is in the XHTML namespace by the way)
It just answers the question in full.
Precise, to the point and relevant for future reference