- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 02:05 AM
Hello developers,
I have an implementation where i get api 400 error and it is returning response in this format:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
From the above response i need to extract what is inside <p> tags. Any help is appreciated, Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 02:44 AM - edited 11-20-2024 03:09 AM
Hello,
You can extract URL from the <p> tag as follows:
var str = "YOUR_RESPONSE";
var url = str.substring(str.indexOf('<p>')+3, str.indexOf('</p>'));
Hope it helps 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 02:44 AM - edited 11-20-2024 03:09 AM
Hello,
You can extract URL from the <p> tag as follows:
var str = "YOUR_RESPONSE";
var url = str.substring(str.indexOf('<p>')+3, str.indexOf('</p>'));
Hope it helps 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 02:45 AM
Hi @servicenow14710
You can get the value on client side something like below, not sure if you are looking to get on server or client.
<!DOCTYPE html>
<html><head>
<script>
function getPtag() {
alert(document.getElementsByTagName("P")[0].innerHTML)
}
</script>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<button onClick="getPtag()" name="GET TAG">GET TAG</button>
</body></html>
Regards,
Harish Murikinati.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 03:05 AM
var startTag = '<p>';
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */