View Single Post
  #1   Report Post  
johnywhy johnywhy is offline
Banned
 
Posts: 3
Default How To Do Relative xPath In CustomXMLNode?

howdy

this code, which loads a KML file, is working great. I'm getting the coordinates of the current oCustomNode:
Code:
Sub Add_Traverse_CustomXMLPart()
    Dim oCustomPart As CustomXMLPart
    Dim oCustomNode As CustomXMLNode
    Dim oCustomNodes As CustomXMLNodes
    
    'Add a Custom XML Part from a file and then load
    Set oCustomPart = ActiveWorkbook.CustomXMLParts.Add
    oCustomPart.Load "C:\Documents and Settings\john\My Documents\Mapping\kml2static\Faith.kml"
    
    'Get Placemarks
    Set oCustomNodes = oCustomPart.SelectNodes("/ns0:kml[1]/ns0:Document[1]/ns0:Placemark")
    For Each oCustomNode In oCustomNodes
        Debug.Print oCustomNode.ChildNodes(8).Text
    Next
    ....
but, would prefer to use relative xPaths, instead of index numbers.

how?

this does not work:
Debug.Print oCustomNode.ChildNodes("Point/coordinates").Text