2 Replies Latest reply on Sep 11, 2006 3:30 PM by mcadle

    CFHTTP Parse page for last row of table

    mcadle Level 1
      Ok, so I need to parse the returned page from a cfhttp call and select the last row in a table. I will then take the value from that row and run another cfhttp to a different page. This will return a html page where I will need to parse that to get the img tag src. Any thoughts?

      Here is some code:

      <cfhttp url=" http://SERVERNAME/GetPhotoEncounters.cgi" method="post" resolveurl="yes">
      <cfhttpparam name="TXTBox" type="formfield" value="17133804">
      </cfhttp>

      It returns (in the source):

      <form method=post name="EncounterInfo" action=" http://SERVERNAME/GeneratePhotos.cgi">
      <table border units=relative width=0.9 colspec="C2 C1 C1 C1 C1 C1 C1 C1 C1">
      <th align=center> <h3>View</h3>
      <th align=center> <h3>NO.</h3>
      <th align=center> <h3>ID</h3>
      <th align=center> <h3>Encounter Type</h3>
      <th align=center> <h3>Date & Time</h3>
      <th align=center> <h3>Type</h3>
      <th align=center> <h3>X System Indicator</h3>
      <th align=center> <h3>Images Location</h3>
      <th align=center> <h3>Database Ind</h3>
      <!-- Data -->
      <tr>
      <td align=center><input type="checkbox" name="eid" value="36659622;06/02/05 13:31:29">
      <td align=center> 36659622
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 06/02/05 13:31:29
      <td align=center> F
      <td align=center> ENF
      <td align=center> 967
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="37070943;06/09/05 14:28:28">
      <td align=center> 37070943
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 06/09/05 14:28:28
      <td align=center> R
      <td align=center> ENF
      <td align=center> 968
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="38114421;06/23/05 19:03:50">
      <td align=center> 38114421
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 06/23/05 19:03:50
      <td align=center> R
      <td align=center> ENF
      <td align=center> 968
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="38216303;06/24/05 22:30:42">
      <td align=center> 38216303
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 06/24/05 22:30:42
      <td align=center> R
      <td align=center> ENF
      <td align=center> 968
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="41424139;08/04/05 22:48:21">
      <td align=center> 41424139
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 08/04/05 22:48:21
      <td align=center> R
      <td align=center> ENF
      <td align=center> 968
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="42971024;08/19/05 11:59:35">
      <td align=center> 42971024
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 08/19/05 11:59:35
      <td align=center> R
      <td align=center> ENF
      <td align=center> 968
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="43676008;09/15/05 00:43:33">
      <td align=center> 43676008
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 09/15/05 00:43:33
      <td align=center> R
      <td align=center> ENF
      <td align=center> 968
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="51501911;02/20/06 01:17:16">
      <td align=center> 51501911
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 02/20/06 01:17:16
      <td align=center> R
      <td align=center> ENF
      <td align=center> 970
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="52543143;03/20/06 06:06:56">
      <td align=center> 52543143
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 03/20/06 06:06:56
      <td align=center> R
      <td align=center> ENF
      <td align=center> 971
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="52812077;03/30/06 08:36:15">
      <td align=center> 52812077
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 03/30/06 08:36:15
      <td align=center> R
      <td align=center> ENF
      <td align=center> 971
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="52983796;04/07/06 15:15:32">
      <td align=center> 52983796
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 04/07/06 15:15:32
      <td align=center> R
      <td align=center> ENF
      <td align=center> 971
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="53243687;04/23/06 14:58:23">
      <td align=center> 53243687
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 04/23/06 14:58:23
      <td align=center> R
      <td align=center> ENF
      <td align=center> 972
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="54447246;06/24/06 00:46:23">
      <td align=center> 54447246
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 06/24/06 00:46:23
      <td align=center> R
      <td align=center> ENF
      <td align=center> 973
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="56717661;07/05/06 06:45:19">
      <td align=center> 56717661
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 07/05/06 06:45:19
      <td align=center> R
      <td align=center> ENF
      <td align=center> 973
      <td align=center> R
      <tr>
      <td align=center><input type="checkbox" name="eid" value="61073876;08/28/06 02:13:33">
      <td align=center> 61073876
      <td align=center> 17133804
      <td align=center> BP
      <td align=center> 08/28/06 02:13:33
      <td align=center> R
      <td align=center> ENF
      <td align=center> 974
      <td align=center> R
      </table>
      </center>
      <p align="left"><input type="checkbox" name="photoOnly"> <p>
      <INPUT TYPE="SUBMIT" NAME="SUBMIT_BUTTON" VALUE="View Photo(s)">
      <INPUT TYPE="BUTTON" NAME="SELECT_ALL_BUTTON" VALUE="Select All" onClick="doSelectAll(15)">
      <INPUT TYPE="RESET" NAME="CLEAR_ALL_BUTTON" VALUE="Clear All">
      <input type="hidden" name="TXTBox" value="17133804">
      <br>
      </form>

      I need the last row of the table's checbox value. This way, I can submit that value to the next page via cfhttp. That would return:

      table border=1>
      <tr>
      <td align="center"><font color="blue" size=4>EID</font>
      <td align="center"><font color="blue" size=4>Date</font>
      <td align="center"><font color="blue" size=4>Photo</font>
      <td align="center"><font color="blue" size=4>Photo</font>
      <td align="center"><font color="blue" size=4>Photo</font>
      <tr>
      <td><b>61073876</b>
      <td><b> 08/28/06 </b><br><b>02:13:33</b>
      <td>
      <img src ="/image_cache/61073876.jpeg" height=200 width=200>
      <td>
      <img src ="/image_cache/61073876_F2.gif" height=200 width=200>
      <td>
      <img src ="/image_cache/61073876_F7.gif" height=200 width=200>
      </table>

      From this, I need to set to variable, the three img tags' src. Then I can insert these values into a local db.

      Help me please as I am drowning on this one!!

      Thanks to all.
        • 1. CFHTTP Parse page for last row of table
          LeftCorner
          You could loop over the file contents and then parse each line using a regular expression to extract your checkbox values and image values. This is code I wrote which gets the last checkbox and an array of images given your example. You may have to adjust the regular expression somewhat if your example isn't the same as the HTML you are parsing.
          • 2. Re: CFHTTP Parse page for last row of table
            mcadle Level 1
            You sir, are like a god to me. Sorry it took so long to post, but I finally was able to check it at the office and it works perfectly. Turned it into a component and wah-lah, I have the perfect piece of code that has eluded me for about 6 months.

            Thank you LeftCorner!!