XSLT To Remove multiple Elements of an XMLXSLT Transform doesn't work until I remove root nodeWhat's the difference between an element and a node in XML?What characters do I need to escape in XML documents?XSLT equivalent for JSONHow do I parse XML in Python?Declaring a custom android UI element using XMLHow do I comment out a block of tags in XML?What does <![CDATA[]]> in XML mean?How do you parse and process HTML/XML in PHP?How to apply multiple transforms in CSS?XSLT To Remove Elements of an XML

How can I answer high-school writing prompts without sounding weird and fake?

Loading Latex packages into Mathematica

Why is LOX on top in the Space Shuttle external tank instead of the other the way round?

Is there ever any indication in the MCU as to how Spider-Man got his powers?

What episode was being referenced by this part of Discovery's season 2 episode 13 recap?

Can someone explain homicide-related death rates?

Is taking modulus on both sides of an equation valid?

When a land becomes a creature, is it untapped?

What is the best way for a skeleton to impersonate human without using magic?

How does emacs `shell-mode` know to prompt for sudo?

Do I need to say 'o`clock'?

Was this character’s old age look CGI or make-up?

Tikzpicture in figure problem

Why do the lights go out when someone enters the dining room on this ship?

Missouri raptors have wild hairdos

Area under the curve - Integrals (Antiderivatives)

Tikz draw contour without some edges, and fill

Extracting sublists that contain similar elements

Is there anything special about -1 (0xFFFFFFFF) regarding ADC?

Frame adjustment for engine

Do Life Drain attacks from wights stack?

Where to find every-day healthy food near Heathrow Airport?

LWC1513: @salesforce/resourceUrl modules only support default imports

Why was Endgame Thanos so different than Infinity War Thanos?



XSLT To Remove multiple Elements of an XML


XSLT Transform doesn't work until I remove root nodeWhat's the difference between an element and a node in XML?What characters do I need to escape in XML documents?XSLT equivalent for JSONHow do I parse XML in Python?Declaring a custom android UI element using XMLHow do I comment out a block of tags in XML?What does <![CDATA[]]> in XML mean?How do you parse and process HTML/XML in PHP?How to apply multiple transforms in CSS?XSLT To Remove Elements of an XML






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have the following XML/KML file (see below just a part of the entire data).



I want to remove specific elements and their contents via XSLT (I'm using Notepad++ with the Plugin XML Tools). The file is very big, and it's mandatory to use XSLT.



I want to remove <Snippet> elements and specific tag/contents from the <description> elements: <p> tags.



For example, one raw entry is like this:



<Placemark><name>Wando</name><Snippet>Record 325</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=325">All data for record 325</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


After XSLT I want to achieve:



<Placemark><name>Wando</name><description><![CDATA[<table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


P.S. It's is possible to remove also the <![CDATA[ + without <table> + ]]>



I really need <table>, for example:



<Placemark><name>Wando</name><description><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


The entire RAW data:



<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.2/"> <Document>
<name>Major mineral deposits of the world</name>
<description>Regional locations and general geologic setting of known deposits of major nonfuel mineral commodities. Originally compiled in five parts by diverse authors, combined here for convenience despite likely inconsistencies among the regional reports.</description>
<Placemark><name>Wando</name><Snippet>Record 325</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=325">All data for record 325</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>
<Placemark><name>McDonald</name><Snippet>Record 549</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=549">All data for record 549</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>United States</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td>Montana</td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>-112.525,47,0</coordinates></Point></Placemark>
<Placemark><name>Montana Mountains</name><Snippet>Record 575</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=575">All data for record 575</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>United States</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td>Nevada</td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>-118.108,41.767,0</coordinates></Point></Placemark>
<Placemark><name>Basay</name><Snippet>Record 429</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=429">All data for record 429</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Philippines</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>122.6333,9.5667,0</coordinates></Point></Placemark>
<Placemark><name>Georgina Basin</name><Snippet>Record 52</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=52">All data for record 52</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Sedimentary</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Australia</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>139.9667,-21.8833,0</coordinates></Point></Placemark>
<Style id="default_highlight"><BalloonStyle><text>Major Mineral Deposits</text></BalloonStyle><IconStyle><scale>1.5</scale><Icon><href>https://mrdata.usgs.gov/images/mine-32.png</href></Icon></IconStyle><LabelStyle><color>ffffffff</color></LabelStyle></Style><Style id="default_normal"><IconStyle><scale>1</scale><Icon><href>https://mrdata.usgs.gov/images/mine-32.png</href></Icon></IconStyle><LabelStyle><color>00ffffff</color></LabelStyle></Style><StyleMap id="defaultStyleMap"><Pair><key>normal</key><styleUrl>#default_normal</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#default_highlight</styleUrl></Pair></StyleMap> </Document> </kml>









share|improve this question




























    0















    I have the following XML/KML file (see below just a part of the entire data).



    I want to remove specific elements and their contents via XSLT (I'm using Notepad++ with the Plugin XML Tools). The file is very big, and it's mandatory to use XSLT.



    I want to remove <Snippet> elements and specific tag/contents from the <description> elements: <p> tags.



    For example, one raw entry is like this:



    <Placemark><name>Wando</name><Snippet>Record 325</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=325">All data for record 325</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


    After XSLT I want to achieve:



    <Placemark><name>Wando</name><description><![CDATA[<table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


    P.S. It's is possible to remove also the <![CDATA[ + without <table> + ]]>



    I really need <table>, for example:



    <Placemark><name>Wando</name><description><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


    The entire RAW data:



    <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.2/"> <Document>
    <name>Major mineral deposits of the world</name>
    <description>Regional locations and general geologic setting of known deposits of major nonfuel mineral commodities. Originally compiled in five parts by diverse authors, combined here for convenience despite likely inconsistencies among the regional reports.</description>
    <Placemark><name>Wando</name><Snippet>Record 325</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=325">All data for record 325</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>
    <Placemark><name>McDonald</name><Snippet>Record 549</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=549">All data for record 549</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>United States</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td>Montana</td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>-112.525,47,0</coordinates></Point></Placemark>
    <Placemark><name>Montana Mountains</name><Snippet>Record 575</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=575">All data for record 575</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>United States</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td>Nevada</td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>-118.108,41.767,0</coordinates></Point></Placemark>
    <Placemark><name>Basay</name><Snippet>Record 429</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=429">All data for record 429</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Philippines</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>122.6333,9.5667,0</coordinates></Point></Placemark>
    <Placemark><name>Georgina Basin</name><Snippet>Record 52</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=52">All data for record 52</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Sedimentary</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Australia</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>139.9667,-21.8833,0</coordinates></Point></Placemark>
    <Style id="default_highlight"><BalloonStyle><text>Major Mineral Deposits</text></BalloonStyle><IconStyle><scale>1.5</scale><Icon><href>https://mrdata.usgs.gov/images/mine-32.png</href></Icon></IconStyle><LabelStyle><color>ffffffff</color></LabelStyle></Style><Style id="default_normal"><IconStyle><scale>1</scale><Icon><href>https://mrdata.usgs.gov/images/mine-32.png</href></Icon></IconStyle><LabelStyle><color>00ffffff</color></LabelStyle></Style><StyleMap id="defaultStyleMap"><Pair><key>normal</key><styleUrl>#default_normal</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#default_highlight</styleUrl></Pair></StyleMap> </Document> </kml>









    share|improve this question
























      0












      0








      0








      I have the following XML/KML file (see below just a part of the entire data).



      I want to remove specific elements and their contents via XSLT (I'm using Notepad++ with the Plugin XML Tools). The file is very big, and it's mandatory to use XSLT.



      I want to remove <Snippet> elements and specific tag/contents from the <description> elements: <p> tags.



      For example, one raw entry is like this:



      <Placemark><name>Wando</name><Snippet>Record 325</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=325">All data for record 325</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


      After XSLT I want to achieve:



      <Placemark><name>Wando</name><description><![CDATA[<table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


      P.S. It's is possible to remove also the <![CDATA[ + without <table> + ]]>



      I really need <table>, for example:



      <Placemark><name>Wando</name><description><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


      The entire RAW data:



      <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.2/"> <Document>
      <name>Major mineral deposits of the world</name>
      <description>Regional locations and general geologic setting of known deposits of major nonfuel mineral commodities. Originally compiled in five parts by diverse authors, combined here for convenience despite likely inconsistencies among the regional reports.</description>
      <Placemark><name>Wando</name><Snippet>Record 325</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=325">All data for record 325</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>
      <Placemark><name>McDonald</name><Snippet>Record 549</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=549">All data for record 549</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>United States</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td>Montana</td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>-112.525,47,0</coordinates></Point></Placemark>
      <Placemark><name>Montana Mountains</name><Snippet>Record 575</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=575">All data for record 575</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>United States</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td>Nevada</td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>-118.108,41.767,0</coordinates></Point></Placemark>
      <Placemark><name>Basay</name><Snippet>Record 429</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=429">All data for record 429</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Philippines</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>122.6333,9.5667,0</coordinates></Point></Placemark>
      <Placemark><name>Georgina Basin</name><Snippet>Record 52</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=52">All data for record 52</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Sedimentary</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Australia</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>139.9667,-21.8833,0</coordinates></Point></Placemark>
      <Style id="default_highlight"><BalloonStyle><text>Major Mineral Deposits</text></BalloonStyle><IconStyle><scale>1.5</scale><Icon><href>https://mrdata.usgs.gov/images/mine-32.png</href></Icon></IconStyle><LabelStyle><color>ffffffff</color></LabelStyle></Style><Style id="default_normal"><IconStyle><scale>1</scale><Icon><href>https://mrdata.usgs.gov/images/mine-32.png</href></Icon></IconStyle><LabelStyle><color>00ffffff</color></LabelStyle></Style><StyleMap id="defaultStyleMap"><Pair><key>normal</key><styleUrl>#default_normal</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#default_highlight</styleUrl></Pair></StyleMap> </Document> </kml>









      share|improve this question














      I have the following XML/KML file (see below just a part of the entire data).



      I want to remove specific elements and their contents via XSLT (I'm using Notepad++ with the Plugin XML Tools). The file is very big, and it's mandatory to use XSLT.



      I want to remove <Snippet> elements and specific tag/contents from the <description> elements: <p> tags.



      For example, one raw entry is like this:



      <Placemark><name>Wando</name><Snippet>Record 325</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=325">All data for record 325</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


      After XSLT I want to achieve:



      <Placemark><name>Wando</name><description><![CDATA[<table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


      P.S. It's is possible to remove also the <![CDATA[ + without <table> + ]]>



      I really need <table>, for example:



      <Placemark><name>Wando</name><description><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>


      The entire RAW data:



      <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.2/"> <Document>
      <name>Major mineral deposits of the world</name>
      <description>Regional locations and general geologic setting of known deposits of major nonfuel mineral commodities. Originally compiled in five parts by diverse authors, combined here for convenience despite likely inconsistencies among the regional reports.</description>
      <Placemark><name>Wando</name><Snippet>Record 325</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=325">All data for record 325</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Korean Peninsula</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>126.6833,34.35,0</coordinates></Point></Placemark>
      <Placemark><name>McDonald</name><Snippet>Record 549</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=549">All data for record 549</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>United States</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td>Montana</td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>-112.525,47,0</coordinates></Point></Placemark>
      <Placemark><name>Montana Mountains</name><Snippet>Record 575</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=575">All data for record 575</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>United States</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td>Nevada</td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>-118.108,41.767,0</coordinates></Point></Placemark>
      <Placemark><name>Basay</name><Snippet>Record 429</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=429">All data for record 429</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Hydrothermal</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Philippines</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>122.6333,9.5667,0</coordinates></Point></Placemark>
      <Placemark><name>Georgina Basin</name><Snippet>Record 52</Snippet><description><![CDATA[<p>Data source: <a href="https://mrdata.usgs.gov/ofr-2005-1294/" title="">Major mineral deposits worldwide</a></p><p>[<a href="https://mrdata.usgs.gov/major-deposits/show-ofr20051294.php?gid=52">All data for record 52</a>]</p><table border='1' padding='3' cellspacing='0'><tr valign='top'><th align='right' bgcolor='#ddffee' title='Generalized type of deposit'>Deposit type</th><td>Sedimentary</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='Country in which the site is located'>Country</th><td>Australia</td></tr><tr valign='top'><th align='right' bgcolor='#ddffee' title='State in which the site is located, for US sites'>State</th><td></td></tr></table>]]></description><styleUrl>#defaultStyleMap</styleUrl><Point><altitudeMode>relativeToGround</altitudeMode><coordinates>139.9667,-21.8833,0</coordinates></Point></Placemark>
      <Style id="default_highlight"><BalloonStyle><text>Major Mineral Deposits</text></BalloonStyle><IconStyle><scale>1.5</scale><Icon><href>https://mrdata.usgs.gov/images/mine-32.png</href></Icon></IconStyle><LabelStyle><color>ffffffff</color></LabelStyle></Style><Style id="default_normal"><IconStyle><scale>1</scale><Icon><href>https://mrdata.usgs.gov/images/mine-32.png</href></Icon></IconStyle><LabelStyle><color>00ffffff</color></LabelStyle></Style><StyleMap id="defaultStyleMap"><Pair><key>normal</key><styleUrl>#default_normal</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#default_highlight</styleUrl></Pair></StyleMap> </Document> </kml>






      xml xslt transform






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 12:49









      Apopei Andrei IonutApopei Andrei Ionut

      156421




      156421






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Removing the Snippet element is trivial: use the identity transform template and add an empty template matching Snippet.



          Converting the raw text data within CDATA sections into a markup is not: try using disable-output-escaping when writing the output to a file, then use another stylesheet to process the resulting file. Or move up to a processor that supports XSLT 3.0 (or has an extension function to enable serializing of escaped markup).




          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39




          Another option you may consider is to "hack" the escaped markup by cutting off the substring preceding the table part using a simple string manipulation:



          XSLT 1.0



          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:strip-space elements="*"/>

          <!-- identity transform -->
          <xsl:template match="@*|node()">
          <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
          </xsl:template>

          <xsl:template match="Snippet"/>

          <xsl:template match="description">
          <xsl:copy>
          <xsl:variable name="len" select="string-length(substring-before(., '&lt;table'))" />
          <xsl:value-of select="substring(., $len + 1)" disable-output-escaping="yes"/>
          </xsl:copy>
          </xsl:template>

          </xsl:stylesheet>



          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39/1






          share|improve this answer

























          • Dear @michael.hor257k When I put multiple lines I got an error, with one row everything works. xsltfiddle.liberty-development.net/6r5Gh39/4

            – Apopei Andrei Ionut
            Mar 23 at 16:21











          • As the error message says, your input is not well-formed XML. An XML document MUST have a single root element. Note also that if your input is a KML document, you must account for the KML namespace - see, for example: stackoverflow.com/questions/34758492/…

            – michael.hor257k
            Mar 23 at 16:26


















          1














          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:template match="Placemark">
          <xsl:element name="Placemark">
          <xsl:copy-of select="name"/>
          <xsl:element name="description">
          <xsl:variable name="finallenght" select="string-length(substring-before(description, '&lt;table'))" />
          <xsl:value-of select="substring(description, $finallenght + 1)" disable-output-escaping="yes"/>
          </xsl:element>
          <xsl:copy-of select="styleUrl"/>
          <xsl:copy-of select="Point"/>
          </xsl:element>
          </xsl:template>
          </xsl:stylesheet>


          You can use this also






          share|improve this answer























          • So what's the big difference between your answer and mine?

            – michael.hor257k
            Mar 23 at 15:20











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313894%2fxslt-to-remove-multiple-elements-of-an-xml%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Removing the Snippet element is trivial: use the identity transform template and add an empty template matching Snippet.



          Converting the raw text data within CDATA sections into a markup is not: try using disable-output-escaping when writing the output to a file, then use another stylesheet to process the resulting file. Or move up to a processor that supports XSLT 3.0 (or has an extension function to enable serializing of escaped markup).




          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39




          Another option you may consider is to "hack" the escaped markup by cutting off the substring preceding the table part using a simple string manipulation:



          XSLT 1.0



          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:strip-space elements="*"/>

          <!-- identity transform -->
          <xsl:template match="@*|node()">
          <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
          </xsl:template>

          <xsl:template match="Snippet"/>

          <xsl:template match="description">
          <xsl:copy>
          <xsl:variable name="len" select="string-length(substring-before(., '&lt;table'))" />
          <xsl:value-of select="substring(., $len + 1)" disable-output-escaping="yes"/>
          </xsl:copy>
          </xsl:template>

          </xsl:stylesheet>



          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39/1






          share|improve this answer

























          • Dear @michael.hor257k When I put multiple lines I got an error, with one row everything works. xsltfiddle.liberty-development.net/6r5Gh39/4

            – Apopei Andrei Ionut
            Mar 23 at 16:21











          • As the error message says, your input is not well-formed XML. An XML document MUST have a single root element. Note also that if your input is a KML document, you must account for the KML namespace - see, for example: stackoverflow.com/questions/34758492/…

            – michael.hor257k
            Mar 23 at 16:26















          1














          Removing the Snippet element is trivial: use the identity transform template and add an empty template matching Snippet.



          Converting the raw text data within CDATA sections into a markup is not: try using disable-output-escaping when writing the output to a file, then use another stylesheet to process the resulting file. Or move up to a processor that supports XSLT 3.0 (or has an extension function to enable serializing of escaped markup).




          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39




          Another option you may consider is to "hack" the escaped markup by cutting off the substring preceding the table part using a simple string manipulation:



          XSLT 1.0



          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:strip-space elements="*"/>

          <!-- identity transform -->
          <xsl:template match="@*|node()">
          <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
          </xsl:template>

          <xsl:template match="Snippet"/>

          <xsl:template match="description">
          <xsl:copy>
          <xsl:variable name="len" select="string-length(substring-before(., '&lt;table'))" />
          <xsl:value-of select="substring(., $len + 1)" disable-output-escaping="yes"/>
          </xsl:copy>
          </xsl:template>

          </xsl:stylesheet>



          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39/1






          share|improve this answer

























          • Dear @michael.hor257k When I put multiple lines I got an error, with one row everything works. xsltfiddle.liberty-development.net/6r5Gh39/4

            – Apopei Andrei Ionut
            Mar 23 at 16:21











          • As the error message says, your input is not well-formed XML. An XML document MUST have a single root element. Note also that if your input is a KML document, you must account for the KML namespace - see, for example: stackoverflow.com/questions/34758492/…

            – michael.hor257k
            Mar 23 at 16:26













          1












          1








          1







          Removing the Snippet element is trivial: use the identity transform template and add an empty template matching Snippet.



          Converting the raw text data within CDATA sections into a markup is not: try using disable-output-escaping when writing the output to a file, then use another stylesheet to process the resulting file. Or move up to a processor that supports XSLT 3.0 (or has an extension function to enable serializing of escaped markup).




          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39




          Another option you may consider is to "hack" the escaped markup by cutting off the substring preceding the table part using a simple string manipulation:



          XSLT 1.0



          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:strip-space elements="*"/>

          <!-- identity transform -->
          <xsl:template match="@*|node()">
          <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
          </xsl:template>

          <xsl:template match="Snippet"/>

          <xsl:template match="description">
          <xsl:copy>
          <xsl:variable name="len" select="string-length(substring-before(., '&lt;table'))" />
          <xsl:value-of select="substring(., $len + 1)" disable-output-escaping="yes"/>
          </xsl:copy>
          </xsl:template>

          </xsl:stylesheet>



          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39/1






          share|improve this answer















          Removing the Snippet element is trivial: use the identity transform template and add an empty template matching Snippet.



          Converting the raw text data within CDATA sections into a markup is not: try using disable-output-escaping when writing the output to a file, then use another stylesheet to process the resulting file. Or move up to a processor that supports XSLT 3.0 (or has an extension function to enable serializing of escaped markup).




          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39




          Another option you may consider is to "hack" the escaped markup by cutting off the substring preceding the table part using a simple string manipulation:



          XSLT 1.0



          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:strip-space elements="*"/>

          <!-- identity transform -->
          <xsl:template match="@*|node()">
          <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
          </xsl:template>

          <xsl:template match="Snippet"/>

          <xsl:template match="description">
          <xsl:copy>
          <xsl:variable name="len" select="string-length(substring-before(., '&lt;table'))" />
          <xsl:value-of select="substring(., $len + 1)" disable-output-escaping="yes"/>
          </xsl:copy>
          </xsl:template>

          </xsl:stylesheet>



          Demo: https://xsltfiddle.liberty-development.net/6r5Gh39/1







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 23 at 14:24

























          answered Mar 23 at 14:05









          michael.hor257kmichael.hor257k

          77.9k42338




          77.9k42338












          • Dear @michael.hor257k When I put multiple lines I got an error, with one row everything works. xsltfiddle.liberty-development.net/6r5Gh39/4

            – Apopei Andrei Ionut
            Mar 23 at 16:21











          • As the error message says, your input is not well-formed XML. An XML document MUST have a single root element. Note also that if your input is a KML document, you must account for the KML namespace - see, for example: stackoverflow.com/questions/34758492/…

            – michael.hor257k
            Mar 23 at 16:26

















          • Dear @michael.hor257k When I put multiple lines I got an error, with one row everything works. xsltfiddle.liberty-development.net/6r5Gh39/4

            – Apopei Andrei Ionut
            Mar 23 at 16:21











          • As the error message says, your input is not well-formed XML. An XML document MUST have a single root element. Note also that if your input is a KML document, you must account for the KML namespace - see, for example: stackoverflow.com/questions/34758492/…

            – michael.hor257k
            Mar 23 at 16:26
















          Dear @michael.hor257k When I put multiple lines I got an error, with one row everything works. xsltfiddle.liberty-development.net/6r5Gh39/4

          – Apopei Andrei Ionut
          Mar 23 at 16:21





          Dear @michael.hor257k When I put multiple lines I got an error, with one row everything works. xsltfiddle.liberty-development.net/6r5Gh39/4

          – Apopei Andrei Ionut
          Mar 23 at 16:21













          As the error message says, your input is not well-formed XML. An XML document MUST have a single root element. Note also that if your input is a KML document, you must account for the KML namespace - see, for example: stackoverflow.com/questions/34758492/…

          – michael.hor257k
          Mar 23 at 16:26





          As the error message says, your input is not well-formed XML. An XML document MUST have a single root element. Note also that if your input is a KML document, you must account for the KML namespace - see, for example: stackoverflow.com/questions/34758492/…

          – michael.hor257k
          Mar 23 at 16:26













          1














          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:template match="Placemark">
          <xsl:element name="Placemark">
          <xsl:copy-of select="name"/>
          <xsl:element name="description">
          <xsl:variable name="finallenght" select="string-length(substring-before(description, '&lt;table'))" />
          <xsl:value-of select="substring(description, $finallenght + 1)" disable-output-escaping="yes"/>
          </xsl:element>
          <xsl:copy-of select="styleUrl"/>
          <xsl:copy-of select="Point"/>
          </xsl:element>
          </xsl:template>
          </xsl:stylesheet>


          You can use this also






          share|improve this answer























          • So what's the big difference between your answer and mine?

            – michael.hor257k
            Mar 23 at 15:20















          1














          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:template match="Placemark">
          <xsl:element name="Placemark">
          <xsl:copy-of select="name"/>
          <xsl:element name="description">
          <xsl:variable name="finallenght" select="string-length(substring-before(description, '&lt;table'))" />
          <xsl:value-of select="substring(description, $finallenght + 1)" disable-output-escaping="yes"/>
          </xsl:element>
          <xsl:copy-of select="styleUrl"/>
          <xsl:copy-of select="Point"/>
          </xsl:element>
          </xsl:template>
          </xsl:stylesheet>


          You can use this also






          share|improve this answer























          • So what's the big difference between your answer and mine?

            – michael.hor257k
            Mar 23 at 15:20













          1












          1








          1







          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:template match="Placemark">
          <xsl:element name="Placemark">
          <xsl:copy-of select="name"/>
          <xsl:element name="description">
          <xsl:variable name="finallenght" select="string-length(substring-before(description, '&lt;table'))" />
          <xsl:value-of select="substring(description, $finallenght + 1)" disable-output-escaping="yes"/>
          </xsl:element>
          <xsl:copy-of select="styleUrl"/>
          <xsl:copy-of select="Point"/>
          </xsl:element>
          </xsl:template>
          </xsl:stylesheet>


          You can use this also






          share|improve this answer













          <xsl:stylesheet version="1.0" 
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:template match="Placemark">
          <xsl:element name="Placemark">
          <xsl:copy-of select="name"/>
          <xsl:element name="description">
          <xsl:variable name="finallenght" select="string-length(substring-before(description, '&lt;table'))" />
          <xsl:value-of select="substring(description, $finallenght + 1)" disable-output-escaping="yes"/>
          </xsl:element>
          <xsl:copy-of select="styleUrl"/>
          <xsl:copy-of select="Point"/>
          </xsl:element>
          </xsl:template>
          </xsl:stylesheet>


          You can use this also







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 14:58









          Nikhil KarandeNikhil Karande

          367




          367












          • So what's the big difference between your answer and mine?

            – michael.hor257k
            Mar 23 at 15:20

















          • So what's the big difference between your answer and mine?

            – michael.hor257k
            Mar 23 at 15:20
















          So what's the big difference between your answer and mine?

          – michael.hor257k
          Mar 23 at 15:20





          So what's the big difference between your answer and mine?

          – michael.hor257k
          Mar 23 at 15:20

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313894%2fxslt-to-remove-multiple-elements-of-an-xml%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript