Consulting

Results 1 to 3 of 3

Thread: MSXML2 - getElementsByTagName()

  1. #1
    VBAX Newbie
    Joined
    Nov 2006
    Posts
    1
    Location

    MSXML2 - getElementsByTagName()

    Hi, I'm pretty unfamiliar with XML, but I'm writing a VBA program in excel that uses the MSN Soap Library to retrieve XML object's from this database on the web. Then I need to extract info from these XML objects and distribute them into a worksheet. Basically, the first part of my code returns an IXMLDOMSelection object, let's call it objX.

    objX has a bunch of child nodes containing the info I want to extract. I'm trying to use the method 'getElementsByTagName(Name As String)' to return nodes matching a particular tagname so that I can get the text from those nodes and put it in the correct place in my worksheet. The problem is, I can't get "getElementsByTagName" to work properly. I searched the internet, and found out that the following command should return all nodes in the object, which it does.
    objX.getElementsByTagName("*")
    So when I look at the tagnames of these nodes and if, for example, the tagname of the 1st node is 'tag', the following command should return just that first node.
    objX.getElementsByTagName("tag")
    However, this is not returning anything at all, and I'm completely baffled as to how to make it work.

    Hopefully someone has some idea of what I'm talking about and can either help me out or tell me I'm going about this the wrong way. Thanks

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Cross Posted http://www.excelforum.com/showthread.php?t=582871

    Please follow this link and read it for an explanation of cross-posting
    http://www.excelguru.ca/node/7
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    the tagname of the 1st node is 'tag', the following command should return just that first node.
    You should use the Item property - using something like
    oXML.GetElementsByTagName("*").Item(1).NodeName should return "tag" in your case. Also, you might want to look into the thread on XML parsing in the Other forum on this board. Stan

Posting Permissions

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