I want to remove all the Placemarks that has a name, and keep the lines which is between , as the performance of the file is awful

I've tried to do it using Notepad++ Replace function using the below

<Placemark>       <name>.*</name>

to be replaced by

<Placemark>       <name></name>

and its not working :(

  • 2
    An XML editor class in your language of choice would be a better tool for the task. – Vince Sep 23 '18 at 13:45
  • I am just trying to remove all the placemarks and keep the path(s) there in the KML file – Hany Abd El Rahman Sep 23 '18 at 14:08
  • I'm with @Vince on this. You might also want to look into using a dedicated XML Editor (e.g. OxygenXML or similar). Using regular expressions with XML can be a bit tricky (so as ahmadhanb says, take a backup first if you use Notepad++!). See also answers to this question on SuperUser – Steven Kay Sep 23 '18 at 15:33

In XSLT 3.0 you can remove all the Placemark elements having a child called name using:

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
    <xsl:mode on-no-match="shallow-copy"/>
    <xsl:template match="Placemark[name]"/>

This sort of job is much better done using XML-aware tools rather than ordinary text editors.

| improve this answer | |

Try to use the following regular expression in Notepad++, but before that take a backup of your KML file:





Also your expression will work after your escape the slash / in </name>





Use Replace All in Notepad++, and if it didn't work, use Replace All in All Opened Documents, assuming that the only file opened is the KML file.

I tested the above expressions and it worked for me.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.