Spongebob Squarepants wrote:
>It's time to bring it around town...
>
>I'm using cfhttp to load and read in the results to CFHTTP.FileContent.
>
>Within the CFHTTP.FileContent is a form in the middle of the page. How can I ignore
>everything from the top of the file and start outputting from the FORM to the /FORM
>and then ignore the rest. I want to only display a certain area of the webpage I'm
>loading.
>
>Can this be done?
>
>
I'm sure there is a way to do this with regular expression, but regex
isn't exactly my fort�, so here is another way to do this.
<cfset start = FindNoCase("<form",cfhttp.FileContent)-5>
<cfset strLength= FindNoCase("</form>",cfhttp.FileContent)-start+7>
<cfset formstring = mid(cfhttp.FileContent,start,strLength)>
Find and FindNoCase return the position at the end of the string, so
FindNoCase("<form",cfhttp.FileContent) returns the position at the end
of <form. In order to find the position at the beginning of <form you
need to substract the length of the substring.
strLength is the length of the string from start to the end of </form>.
Using start and strLength I can now use mid to grab the middle out of
the cfhttp.filecontent.
A word of warning. When I build forms I have a tendance to nest the
form tags inside the top and bottom of the a table eg.
table
form
tablerow
form content
endtablerow
endform
endtable
The reason for this is that a form tag will create unwanted space around
itself in some browsers. By nesting it inside the table, the table takes
precedence over the form in the display. What I'm getting at is that if
you grab the form out of the middle of the page there is a chance that
you will end up with a chunk of malformed HTML, because its missing
start and end table tags, etc.
Hope this helps
Regards
Stephen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Sams Teach Yourself Regular Expressions in 10 Minutes by Ben Forta
http://www.houseoffusion.com/banners/view.cfm?bannerid=40
Message: http://www.houseoffusion.com/lists.cfm/link=i:15:456
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54