1

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
2

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]"/>
</xsl:transform>

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

0

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

Find:

<name>[A-Za-z1-9]+<\/name>

Replace:

<name></name>

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

Find:

<name>.+<\/name>

Replace:

<name></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.

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.