Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't retrieve text from <th> HTML tag
#1
This code:
Macro TimeCard
Code:
Copy      Help
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?
#2
Cannot test your HTML.
This works.
Macro Macro1913
Code:
Copy      Help
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
#3
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
Code:
Copy      Help
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">&nbsp;</th>
;</table>
;</body></html>

str s
HtmlDoc doc
doc.InitFromText(w)
s=doc.GetText("th" "grdTCardDtl_c_0_1")
out s
#4
Macro Macro1913
Code:
Copy      Help
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">&nbsp;</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
#5
That works. Thank you!


Forum Jump:


Users browsing this thread: 1 Guest(s)