I already used document.getElementById, but it does not work any more. I want to get the value of 0,01€ but I can not. I want to save it in my NSString *price
but how.
The HTML code is
<tr class="price">
<td>0,01</td>
<td>EUR</td>
My idea was
NSString *price = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('price.td').innerText;"];
The tagName in this case is 'td' not 'price.td', but if you run document.getElementsByTagName('id')
you will get all the table cells in the page which is probably not what you want.
If the page has jQuery loaded in it you can use jQuery('.price td:first').text()
to get the price.
If it doesn't have jQuery but you have control of the page you can add a class to it (<td class="my-price">12.44</td>
) and get it with document.getElementsByClassName('my-price')[0].innerHTML
.
If you don't have control of the page and it doesn't have jQuery you will have to find the 'price' row and then get its 1-st cell by using document.getElementsByClassName('my-price')[0].childNodes[0].innerHTML
.