Results 1 to 2 of 2

Thread: Sanity Check Please - XML DOM getElementsByTagName

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Aiken, SC
    Posts
    36

    Sanity Check Please - XML DOM getElementsByTagName

    Hey,

    So here is my problem, I have this xml file (attached). And for some reason whenever I try to get a hold on the noteinfo Element, it won't. The problem originated in a large project I have been working on, and so I wrote this test app (also attached) to see if the problem was a bug in my other code. So here it is, anything wrong with my code? Try out the app... see what I mean... Wierd. I just wanted to run it by some other vbProgramers to be sure I am not loosing my marbles, before I re-write it to use SAX. (which I have wanted to do anyways)

    VB Code:
    1. Dim dxlDoc As MSXML2.DOMDocument40
    2.     Dim nodeList As MSXML2.IXMLDOMNodeList
    3.     Set dxlDoc = New MSXML2.DOMDocument40
    4.     Call dxlDoc.loadXML(getFile(strFileName))
    5.     Set nodeList = dxlDoc.documentElement.getElementsByTagName("noteinfo")
    6.     MsgBox nodeList.length

    btw... the XML file is a Lotus Notes Document that has been exported to DXL (Domino XML)

    To use the program (IRPeek) just click the Load IR button, select the xml file, then click on the test button below the treeview to test the getElementsByTagName.

    Thanks,

    Joey Novak
    Attached Files Attached Files
    You have no idea how many idiots there are among us.

    Winsock is awesome!
    If you are reading this, your a geek, just face it.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Gues what, you almost had it......
    Try this:
    VB Code:
    1. Dim dxlDoc As MSXML2.DOMDocument40
    2.     Dim nodeList As MSXML2.IXMLDOMNodeList
    3.     Set dxlDoc = New MSXML2.DOMDocument40
    4.     Call dxlDoc.loadXML(getFile(strFileName))
    5.     'If you know there is only one node by this name....
    6.     Set nodeList = dxlDoc.documentElement.selectSingleNode("noteinfo")
    7.     MsgBox nodeList.length
    8.     'If there may be more than one.....Even if there is only one, this will still work.
    9.     Set nodeList = dxlDoc.documentElement.selectNodes("noteinfo")
    10.     MsgBox nodeList.length
    BTW: the .length of a NodeList will return the number of elements in the node list (ie, the number of times "noteinfo" nodes appear, not the number of children. BUT, if you want the cound of children nodes... try
    VB Code:
    1. MsgBox nodeList.childNodes.length
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

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



Click Here to Expand Forum to Full Width