delect topics with no children

  • 1
  • Question
  • Updated 1 month ago
I'm a newby-please be gentle. :) I import XML files into a map. This works beautifully. However, some of the elements in the XML contain no data, i.e. the XML element looks like <city></city> and appears in the map as a topic with no subtopics or data. See "City" below.

Does anyone know how to select all of these? Do I need a macro? Any suggestions on the macro? I've never written one for this program. Thanks very much!
Photo of Jerry Johns

Jerry Johns

  • 2 Posts
  • 0 Reply Likes

Posted 1 month ago

  • 1
Photo of Nick Duffill

Nick Duffill, Champion

  • 544 Posts
  • 195 Reply Likes
Hello Jerry

A fun challenge... because it is probably more sophisticated than it first appears.

The following macro will select all the leaf nodes from (unfiltered) topics in the map.
'#Language "WWB-COM"
Option Explicit
Sub Main
Dim m_Topic As Topic
ActiveDocument.Selection.RemoveAll
For Each m_Topic In ActiveDocument.Range(mmRangeAllTopics, False)
If m_Topic.AllSubTopics.Count = 0 Then
ActiveDocument.Selection.Add(m_Topic)
End If
Next 
End Sub

This works, but will select "GA" and "31210" in your example above, which might not be what you intended. It is easy to see visually that "City" and "Streename" are empty, but not quite so straightforward programmatically. You might need to add a term that only looks for childless topics that are also blue hexagons, or that have siblings with children.
Photo of Jerry Johns

Jerry Johns

  • 2 Posts
  • 0 Reply Likes
Hey, thanks very much!