JSFiddle - React, Tailwind, and code Playground
by Fagner Brack
JavaScript
const response = `
<section>
<h1>Locations</h1>
<p>
<strong>Sydney</strong>
<ul>
<li class="sydney-latitude">-33.865143</li>
<li>151.209900</li>
</ul>
</p>
</section>
`;
const getLatitudeFrom = (response) => {
const parsedMessage = new DOMParser().parseFromString(response, 'text/html');
const value = [...parsedMessage.querySelectorAll('[class="sydney-latitude"]')]
.map((element) => element.innerHTML);
alert('The latitude of Sydney is ' + value.join(', '));
};
getLatitudeFrom(response);