Hello,

I'm trying to understan how DOM works.

I have xml etc.:

Code:
<root>
  <file>
    <Filename>file1.txt</Filename>
    <Atributes>
      <Atribute>ReadOnly</Atribute>
      <Atribute>Hidden</Atribute>
    </Atributes> 
  </file>
  <file>
    <Filename>file2.txt</Filename>
    <Atributes>
      <Atribute>Hidden</Atribute>
    </Atributes> 
  </file>
</root>
To select file "file2.txt" I use this code:

VB Code:
  1. Dim oXMLDoc As MSXML2.DOMDocument40
  2. Dim oXMLNode As MSXML2.IXMLDOMNode
  3. Dim oXMLNodeList As MSXML2.IXMLDOMNodeList
  4. Set oXMLDoc = New MSXML2.DOMDocument40
  5.  
  6. oXMLDoc.async = False
  7. oXMLDoc.resolveExternals = True
  8.  
  9. oXMLDoc.Load ("C:\files.xml")
  10. oXMLDoc.setProperty "SelectionLanguage", "XPath"
  11.  
  12. Set oXMLNodeList = oXMLDoc.selectNodes("/root/file[Filename='file2.txt']")
  13.  
  14. If oXMLNodeList.length <> 1 Then
  15. exit sub 'there is 0 or more files with same filename
  16. else
  17. 'now I want to read all atributes to string
  18.  
  19. For Each oXMLNode In oXMLNodeList(0).selectNodes("//Atribute")
  20. Atributes = Atributes & oXMLNode.Text  & ", "
  21. Next
  22.  
  23. end if

It retunrs "ReadOnly, Hidden, Hidden, " but not only result for that file ("Hidden")

I do know want to use loops, becourse it must be as fast as can be.