This is the response i got. I want to extract the <span>
tag from price_html
"id": 2320,
"name": "Lakme Sun Expert Sunscreen (spf-50) 50ml",
"slug": "lakme-sun-expert-sunscreen-spf-50-50ml",
"permalink": "https://www.utkalmerchandise.com/product/lakme-sun-expert-sunscreen-spf-50-50ml/",
"date_created": "2020-08-01T05:49:57",
"date_created_gmt": "2020-08-01T05:49:57",
"date_modified": "2020-08-01T05:49:57",
"date_modified_gmt": "2020-08-01T05:49:57",
"type": "variable",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "",
"short_description": "",
"sku": "",
"price": "95",
"regular_price": "",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"price_html": "<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">₹</span>95.00</span> – <span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">₹</span>219.00</span>",```
2
Answers
just reference the object
If you have it as a string you can use
which will return the index of the first char in the search string. Then you add the length of the search string to that index and save to index. Then you can do
string.indexOf("</", index)
to get the end of the content. And withstring.subString(indexStart, indexEnd)
you get the content.Edit: If you can’t get it to work with that take a look at the org.json package which is really useful when working with java and json.