Use javascript to get TR contents

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nitinkcv
    New Member
    • Mar 2007
    • 65

    Use javascript to get TR contents

    Hi all,

    I'm writing a greasemonkey script wherein i make a GM_XmlHttpReque st to a site and get back a response. This response.respon seText gives me the html source of the page.

    However the web page is built awfully and is now well formed. As a result i'm not able to build XMLObject properly as it gives a parsererror. I've tried to make the html better but there are too many to fix.

    So what i was thinking is that, i would get only the block of TR that's useful to me. I've using RegExp but they don't seem to work.

    There is at least some 25 tags that are inside the TR that i'm trying to get.

    Is there any way i can do this?

    Thanks.
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Use you can get it, just add a comment line before and end of the <tr> with those 25 tags inside. When you get the response text just find the comments

    Dummy Code/ Ex Code
    Code:
    var myStr = GM_XmlHttpRequest.responseText;
    var firstInd = myStr.indexOf("The Comment");
    var lastInd = myStr.lastIndexOf("The Comment");
    var desiredString= myStr.substring(firstInd,lastInd);
    This is a suggestion. There may be lot of solution to achieve your requirement. try this

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • Nitinkcv
      New Member
      • Mar 2007
      • 65

      #3
      Hmmm that is one way. But the problem is that i just get the html source of the page and not sure if i can add the comments.

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        Otherwise check that wether that particular tr has any id or name so that you can find with that id/name.

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        Working...