+ Reply to Thread
Results 1 to 6 of 6

Conditional "getElementsByTagName"

  1. #1
    Registered User
    Join Date
    11-29-2004
    Posts
    5

    Conditional "getElementsByTagName"

    I am an HTML newbie and have played around with this for many hours, without any luck.

    I'm trying to copy all the "DIV" and "TD" elements from one object (elAttrLevel1) to another one (elAttrLevel1a). My code below always shows "elAttrLevel1a" as empty;


    Please Login or Register  to view this content.

    Does anyone know of a way to create such a conditional routine?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Conditional "getElementsByTagName"

    Hello 99bobster99,

    Welcome to the Forum!

    It isn't clear to me what you want to do.

    HTML is a tree structure. The objects have a hierarchical relationship to each other. Objects have parents, children, and siblings. The parent or root of all other HTML objects is the DOM Object or Document Object Model.

    The property getElementsByTagName creates a zero based array of objects that match a Tag Name like DIV. There are no wildcards used in HTML syntax. The array will not include any of the other objects in the tree with them like children or siblings. It returns only that object and it's properties.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    11-29-2004
    Posts
    5

    Re: Conditional "getElementsByTagName"

    Hello Leith,

    Thank you for your reply!

    What I am trying to accomplish is extract all the <DIV> and <TD> node's innertext, in the order this innertext appears on the webpage.

    If I get all the "<DIV>" elements and then all the "<TD>" element innertext (using 2 separate set commands), the combined innertext data will not be in sequential order.

    My thought was to grab all the elements, then conditionally capture each <DIV> and <TD> node's innertext as it appears on the webpage. I found the "clonenode" and "importnode" methods, that look like they can copy nodes from one HTML document to another. Is this something that could be used to keep the innertext data in sequential order?
    Last edited by 99bobster99; 01-17-2017 at 04:30 PM.

  4. #4
    Registered User
    Join Date
    11-29-2004
    Posts
    5
    Quote Originally Posted by 99bobster99 View Post
    Hello Leith,

    Thank you for your reply!

    What I am trying to accomplish is extract all the <DIV> and <TD> node's innertext, in the order this innertext appears on the webpage.

    If I get all the "<DIV>" elements and then all the "<TD>" element innertext (using 2 separate set commands), the combined innertext data will not be in sequential order.

    My thought was to grab all the elements, then conditionally capture each <DIV> and <TD> node's innertext as it appears on the webpage. I found the "clonenode" and "importnode" methods, that look like they can copy nodes from one HTML document to another. Is this something that could be used to keep the innertext data in sequential order?

    Maybe a better way to say this is, how do you copy selected nodes from one HTML document to another HTML document? I'd like to select all the <DIV> & <TD> nodes from one document and copy them to a blank HTML document, in the same order as the appear in the original webpage. Would this be possible?
    Last edited by 99bobster99; 01-18-2017 at 03:15 PM.

  5. #5
    Registered User
    Join Date
    11-29-2004
    Posts
    5

    Re: Conditional "getElementsByTagName"

    I'm making some headway here !!

    Okay, I've gotten this far, it is almost working, I just need some assistance on the "cloneNode" method.

    I am trying to copy only the "DIV" and "TD" nodes to a new HTML document.

    Can someone tell me why neither of the (2) cloneNode will work? They show an error 80004005 (Unspecified Error);


    Please Login or Register  to view this content.

    I am using Microsoft XML 6.0
    Last edited by 99bobster99; 01-18-2017 at 07:00 PM.

  6. #6
    Registered User
    Join Date
    11-29-2004
    Posts
    5

    Re: Conditional "getElementsByTagName"

    Folks, why is this so difficult to figure out?

    Nothing seems to work, all I want to do is clone a node (this is working) from one HTML document and append it to another HTML document (not working);

    See screenshots below, any help on what I am doing wrong would be greatly appreciated.

    XML CloneNode.jpg
    Last edited by 99bobster99; 01-18-2017 at 08:33 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 02-05-2019, 12:03 AM
  2. [SOLVED] formula help: conditional format of one column based on "YES"/"NO" content of four others!
    By 10 Dollar Bill in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-20-2014, 01:59 PM
  3. Conditional formatting by testing for "True" or "False"
    By Excel_vba in forum Excel General
    Replies: 2
    Last Post: 02-21-2014, 11:26 PM
  4. getElementsByTagName("table") unable to access table data using IE10
    By kingnismo in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-04-2013, 06:46 PM
  5. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  6. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  7. Replies: 2
    Last Post: 08-17-2012, 05:10 AM

Tags for this Thread

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1