Posts: 48
Threads: 18
Joined: May 2011
This code:
Macro
TimeCard
HtmlDoc doc
doc.InitFromInternetExplorer(w)
s=doc.GetText("th" "grdTCardDtl_c_0_1")
out s
Gives me this error:
Error (RT) in TimeCard: object not found (container). ?
Even though the HTML code contains:
<th id='grdTCardDtl_c_0_1' columnNo='1' height='30px' class="ig_6a760250_r4 ig_6a760250_2"><nobr>Dist. Code</nobr></th>
Is there a way to get the text from a <th> tag using the id?
Posts: 12,087
Threads: 142
Joined: Dec 2002
Cannot test your HTML.
This works.
Macro
Macro1913
str w=
;<html><head></head><body>
;<table>
;<th id='grdTCardDtl_c_0_1' columnNo='1' height='30px' class="ig_6a760250_r4 ig_6a760250_2"><nobr>Dist. Code</nobr></th>
;</table>
;</body></html>
str s
HtmlDoc doc
doc.InitFromText(w)
s=doc.GetText("th" "grdTCardDtl_c_0_1")
out s
Posts: 48
Threads: 18
Joined: May 2011
Looks like the id is duplicated in two different tables.
Of course, I can't change the HTML source.
Is there a way to specify which <th> tag to get the text from?
Here is an abbreviated example that re-creates the failure:
Macro
Macro
str w=
;<html><head></head><body>
;<table>
;<th id='grdTCardDtl_c_0_1' columnNo='1' height='30px' class="ig_6a760250_r4 ig_6a760250_2"><nobr>Dist. Code</nobr></th>
;</table>
;<table>
;<th id='grdTCardDtl_c_0_1' columnNo='1' height='30px' class="ig_6a760250_r4 ig_6a760250_2"> </th>
;</table>
;</body></html>
str s
HtmlDoc doc
doc.InitFromText(w)
s=doc.GetText("th" "grdTCardDtl_c_0_1")
out s
Posts: 12,087
Threads: 142
Joined: Dec 2002
Macro
Macro1913
str w=
;<html><head></head><body>
;<table>
;<th id='grdTCardDtl_c_0_1' columnNo='1' height='30px' class="ig_6a760250_r4 ig_6a760250_2"><nobr>Dist. Code</nobr></th>
;</table>
;<table>
;<th id='grdTCardDtl_c_0_1' columnNo='1' height='30px' class="ig_6a760250_r4 ig_6a760250_2"> </th>
;</table>
;</body></html>
str s
HtmlDoc doc
doc.InitFromText(w)
ARRAY(MSHTML.IHTMLElement) a; int i
doc.GetHtmlElements(a "th")
for i 0 a.len
,sel a[i].id
,,case "grdTCardDtl_c_0_1"
,,s=a[i].innerText
,,out s
Posts: 48
Threads: 18
Joined: May 2011