Finding the contents of a table cell with JavaScript
3 replies, posted
I'm working on an iPhone application that extracts data from a website and displays it in a more user-friendly text box. Everything works fine and dandy, however, now that I've come up to the last element, I need to extract text from a table on a website.
Basically what I want to do is find the balance, in this case '$17.28' from 'results_table', and have that stored in a variable. I've looked around on google with no real luck.
[html]
<table cellpadding="0" cellspacing="0">
<tr>
<td class="scroll_pane">
<table width="720" cellspacing="1" class="results_table">
<tr>
<th width="50%">As Of</th>
<th>Card Balance</th>
</tr>
<tr>
<td>04-Dec-09 07:16:06 PM</td>
<td>$17.28</td>
</tr>
</table>
</td>
</tr>
</table>[/html]
Since '$17.28' is a dynamic value, is it possible to just display the contents of the second cell of the table? That'd be a whole lot more convenient than finding an actual text match.
Look into [url=https://developer.mozilla.org/En/ChildNodes]Node.childNodes[/url] or [url=https://developer.mozilla.org/en/DOM/Element.children]Element.children[/url].
They're links to the Mozilla Developer Center, but it's all javascript so it should work on WebKit too
Jquery?
I've tried a variety of methods now, currently just displaying the values I'm getting with alert boxes, which unfortunately isn't giving me any results so far.
My question closely resembles a topic I found here:
[url]http://bytes.com/topic/javascript/answers/92166-get-table-cell-value[/url]
Sadly that topic was never answered with a working solution for Webkit :(.
Alternatively I'm trying to find the exact opposite of the [b][i]stringByEvaluatingJavaScriptFromString:[/i][/b] function so I can just copy it to a textview and make it appear there.
Sorry, you need to Log In to post a reply to this thread.