Parsing HTML data

samadam
Kilo Sage

I have a response from web service in html format. I need to parse that out to extract the values. What is a good way to extract the data? Is there a way to convert html to xml and then parse the data? 

Thanks

 

8 REPLIES 8

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

Can you show sample data. Let me look into this and give you the script.

Thanks,
Ashutosh

samadam
Kilo Sage

Here is the sample

<!DOCTYPE html>

<html lang="en-us" class="no-js not-ie">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">

 

&lt;input class=&quot;form-control col-sm-12&quot; aria-label=&quot;Store Code&quot; disabled=&quot;disabled&quot; type=&quot;text&quot; value=&quot;23456&quot; name=&quot;name" id="user_name" /> </div>

<div class="entity-detail-form-group"> <label class="col-sm-12" for="store_description">Description</label>

<input class="form-control col-sm-12" aria-label="Store Description" disabled="disabled" type="text" value="test" name="store[description]" id="store_description" /> </div> <div class="entity-detail-form-group"> <label class="col-sm-12" for="store_loc_code">Store code</label> <input class="form-control col-sm-12" aria-label="Store Code" disabled="disabled" type="text" value="store23" name="store[office_code]" id="store_office_code" /> </div> <div class="entity-detail-form-group"> </div> <div class="entity-detail-form-group"> <label class="col-xs-6" for="store_active">Active</label>


{"text":Store1234",href:"1234","store code":"1234","description":"NewJersey store","store_office_code":"NJH","active":"true}
{"text":Store789",href:"789","store code":"789","description":"Newyork store","store_office_code":"NYS","active":"true}

I need to parse the data to get the values separately.

Hi,

can you give us how you are calling the endpoint?

how you are getting the response?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I believe any integration should have either xml or json as response so that you can parse it

Can you share sample response received?

I suspect it would be in xml format

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader