one line in that page is like this:
<td id="mo1"colspan="3" align="center"><strong> May 2014</strong></td>
how can I in VFP get the May 2014 out of the TD with an id="mo1" (which is unique in that page
is there a oHTTP.something.method to fetch this?
or do I have to do a strextr() or something?
Thanks
Peter
please save this code in a .prg and execute:
text to s noshow flags 1
<table>
<tbody>
<tr>
<td id="mo0" colspan="3" align="center"><strong> May 2010</strong></td>
<TD id="mo1" colspan="3" align="center"><strong> May 2014</strong></td>
<td id="mo2" colspan="3" align="center"><strong> May 2011</strong></td>
<td id="mo3" colspan="3" align="center"><strong> May 2012</strong></td>
<td id="mo4" align="center"><strong> May 2013</strong></td>
</tr>
</tbody>
</table>
endtext? regexp_cortiel(m.s)
* -------------------------
function regexp_cortiel(s)local result;
, regEx1, tds as Collection, td;
, regEx2;result = ''
regEx1 = CreateObject('VBscript.RegExp')
regEx1.Pattern = '<td[^>]+?>'
regEx1.IgnoreCase = .T.
regEx1.Global = .T.
tds = m.regEx1.execute(m.s)
if m.tds.count > 0
regEx2 = CreateObject('VBscript.RegExp')
regEx2.Pattern = 'id\s*=\s*"mo1"'
regEx2.IgnoreCase = .T.
for each td in m.tds
if m.regEx2.test(m.td.Value)
result = Substr(m.s, m.td.firstIndex + 1 + m.td.length) && fox strings are 1-based
result = StrExtract(m.result, '>', '<')
exit
endif
endfor
endifreturn m.result
i am now getting my oHTTP object
one line in that page is like this:
<td id="mo1"colspan="3" align="center"><strong> May 2014</strong></td>
how can I in VFP get the May 2014 out of the TD with an id="mo1" (which is unique in that page)
is there a oHTTP.something.method to fetch this?
or do I have to do a strextr() or something?
Thanks
Peter
-- thn (FoxInCloud)
text to s noshow flags 1
<table>
<tbody>
<tr>
<td id="mo0" colspan="3" align="center"><strong> May 2010</strong></td>
<TD id="mo1" colspan="3" align="center"><strong> May 2014</strong></td>
<td id="mo2" colspan="3" align="center"><strong> May 2011</strong></td>
<td id="mo3" colspan="3" align="center"><strong> May 2012</strong></td>
<td id="mo4" align="center"><strong> May 2013</strong></td>
</tr>
</tbody>
</table>
endtext? regexp_cortiel(m.s)
* -------------------------
function regexp_cortiel(s)local result;
, regEx1, tds as Collection, td;
, regEx2;
, regEx3;result = ''
regEx1 = CreateObject('VBscript.RegExp')
regEx1.Pattern = '<td[^>]+?>' && finds all <td> tags
regEx1.IgnoreCase = .T.
regEx1.Global = .T.
tds = m.regEx1.execute(m.s)
if m.tds.count > 0
regEx2 = CreateObject('VBscript.RegExp')
regEx2.Pattern = 'id\s*=\s*"mo1"' && finds the td tag with desired id
regEx2.IgnoreCase = .T.
for each td in m.tds
if m.regEx2.test(m.td.Value)
result = Substr(m.s, m.td.firstIndex + 1 + m.td.length) && after <td> && fox strings are 1-based
result = Left(m.result, Atc('</td>', m.result) - 1) && before </td>
regEx3 = CreateObject('VBscript.RegExp')
regEx3.Pattern = '<\/?\w(?:[^"' + "'>]" + '|"[^"]*"|' + "'[^']*')*>" && strips html tags from contents
regEx3.IgnoreCase = .T.
regEx3.Global = .T.
result = regEx3.replace(m.result, '')
exit
endif
endfor
endifreturn m.result
i am now getting my oHTTP object
one line in that page is like this:
<td id="mo1"colspan="3" align="center"><strong> May 2014</strong></td>
how can I in VFP get the May 2014 out of the TD with an id="mo1" (which is unique in that page
is there a oHTTP.something.method to fetch this?
or do I have to do a strextr() or something?
Thanks
Peter
-- thn (FoxInCloud)
Extract() is pretty easy:
lcDate = Extract(lcHtml,[<td id="] + id + ["colspan="3" align="center"><strong>],[</strong></td>])
Note StrExtract would probably work too - using Extract from wwUtils.prg.
+++ Rick ---
i am now getting my oHTTP object
one line in that page is like this:
<td id="mo1"colspan="3" align="center"><strong> May 2014</strong></td>
how can I in VFP get the May 2014 out of the TD with an id="mo1" (which is unique in that page
is there a oHTTP.something.method to fetch this?
or do I have to do a strextr() or something?
Thanks
Peter
West Wind Technologies
Making waves on the Web
from Maui