Read XML file in VBA

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)


I’m busy with a VBA code that determines if a lat/long point lies in a specified area. My areas are defined in kml files from Google earth. I’ve uploaded an example of one one of my kml area files “Bhekela – v1.kml”.

My question is, in VBA, how do I automate the process of extracting the coordinates that form polygon points of the area. What I want to do is to read the “Bhekela – v1.kml” file and extract the coordinates inside the tags (see below) ”
28.25959909739643,-31.20619763209652,0 28.26071545752565,-31.19702465776928,0 28.25085444969957,-31.19927874343989,0 28.24923203195886,-31.20652374573175,0 28.25959909739643,-31.20619763209652,0

I want read the data inside the tags and present it is the format below. pPoint is an array. The data below represents polygon points of a Bhekela area.

pPoint(17, 1) = -31.2061976320965: pPoint(17, 2) = 28.2595990973964
pPoint(17, 3) = -31.1970246577692: pPoint(17, 4) = 28.2607154575256
pPoint(17, 5) = -31.1992787434398: pPoint(17, 6) = 28.2508544496995
pPoint(17, 7) = -31.2065237457317: pPoint(17, 8) = 28.2492320319588
pPoint(17, 9) = -31.2061976320965: pPoint(17, 10) = 28.2595990973964

Can anyone help show me how to do this? I know how to program in VB but not an expert.

Tnx in anticipation

Simply the best place to learn Excel VBA