AJAX read specific id tag & count tag in external html

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lu5ck
    New Member
    • Aug 2008
    • 2

    AJAX read specific id tag & count tag in external html

    Hi all,

    How do you read specific div id in a external html returned from resposnetext?
    Also, is it possible to count how many div tag are there in the resposnetext?

    Been googling and can't find any help to this...
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    If you add it to the page, you can use document.getEle mentById().

    Comment

    • Lu5ck
      New Member
      • Aug 2008
      • 2

      #3
      Hi,
      Thanks for the reply.

      To be precise, I wanted to retrieve a specific id tag from responsetext. For example, in that html, there is a <div> tag that goes by id "hello". I want to retrieve the content in that <div> tag and put it up on the page.

      BTW, how to use regular expression to count the amount of matched content?

      Thanks & Regards,

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        OK, I was giving you the easy solution. If you want to use regular expressions, match a div with id "hello" and grab its content with (), e.g. :
        [code=javascript]/<div id="hello" [^>]*>(.*?)<\/div>/[/code](not tested)

        Comment

        Working...