SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Delete HTML table columns?

    We have an agreement with another site to maintain some data for us. Because they won't make the data available via XML or give us DB accesss, I'm using CFHTTP to do some screen-scraping. However, I only want to use a few columns of the HTML table I am getting. I'm fairly new to CF and am not seeing a way that I can capture a specific number of columns (or delete a specific number of columns).

    In other languages (maybe FoxPro?), there was a function that would tell me the position of the nth occurrence of a string, but I'm not seeing a similar function in CF. Can someone get me pointed in the right direction?

    Thanks,
    John

  2. #2
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, no such table manipulation functions are available via ColdFusion. Giving you the data in HTML only is pretty weak, imo. But beyond that, if there's absolutely no way to get the data, you'll have to do some manipulation.

    If I had to do this, I would probably start by stripping out everything but the table. Then, I'd use the List Functions to break the data down into rows, and then break the rows down into columns. Then do whatever you want with the data inside.

    Good Luck!

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Chris.

    I've already gotten the table extracted and all of the style IDs extracted and the missing TDs added...

    Because I know the # of columns, I was hoping to find an instr() or similar function that would let me look for the 5th occurrence of the TD tag. Then I was going to do a Left() up until that point. Instead, it sounds like I'll have to set up a loop to move each cell, one at a time, 'X' number of times.

    John

  4. #4
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a very simple way to find various things. To find the 5th occurence of a TD tag you'd just need to do this:

    Find("<td",yourString [, start position])

    Finds the first occurrence of a substring in a string, from a specified start position. The search is case-sensitive.

    I heartily recommend the use of CfQuickDocs for ColdFusion reference.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a very simple way to find various things. To find the 5th occurence of a TD tag you'd just need to do this:

    Find("<td",yourString [, start position])
    But that doesn't find the fifth occurence, it only finds the first occurence. the start position doesn't help because the length of the cell data varies. Unless I'm missing something.

    What I'll need to do is loop through the FIND() a specific number of times (in this case, 6), then utilize a LEFT() to grab the first six columns. I was wondering if it could be done without a loop.

    Thanks,
    John


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •