Forum Discussion

soaptes123's avatar
soaptes123
Occasional Contributor
11 years ago

How to parse HTML response

Hi,

when iam calling Rest Webservice.iam getting response in "HTML".How Can I parse it and validate it using groovy or any other.

5 Replies

  • soaptes123's avatar
    soaptes123
    Occasional Contributor
    Yes, when I call the Rest api .in the response header

    Content-Type: text/html;charset=ISO-8859-1



    My response is kind of


    <div id="defaultBaselineData">

    <table class="baseTable" style="margin-left: 10px;">
    <tbody>
    <tr>
    <td style="width: 10%;">Year</td>

    <td><label id="yearLabel1"></label></td>

    <td><label id="yearLabel2"></label></td>

    <td><label id="yearLabel3"></label></td>

    <td><label id="yearLabel4"></label></td>

    <td><label id="yearLabel5"></label></td>

    <td><label id="yearLabel6"></label></td>

    <td><label id="yearLabel7"></label></td>

    <td><label id="yearLabel8"></label></td>

    <td><label id="yearLabel9"></label></td>

    <td><label id="yearLabel10"></label></td>

    <td><label id="yearLabel11"></label></td>

    <td><label id="yearLabel12"></label></td>

    <td>12 Months</td>
    <td>Select</td>
    <td style="text-align: right !important">
    <button title="Edit Dates" data-behaviors-eager="Plugin.Button"
    type="button" onclick="baselineDatePicker();">Edit Dates</button>
    </td>
    </tr>
    <tr>
  • nmrao's avatar
    nmrao
    Community Hero
    Is there any thing specific you would like to do on response? html is like xml only right?
  • soaptes123's avatar
    soaptes123
    Occasional Contributor
    Currently what I was doing is data which I was getting from DB I was converting to XML.But my API response I was getting in HTML only.How can I parse html response in XML ?I need to validate those response. I was looking for groovy code .I don't have idea how to parse it .Any example that we be helpful!!
  • nmrao's avatar
    nmrao
    Community Hero
    You mean compare this html with the DB xml (would you mind posting it)? You may generate an xml outof html in groovy script step.