Filter large XML file with xslt and child contains text -


i have large xml file (20 mb) , want make smaller filtering relevant elements. filtering need nodes element "allterms" contains word "energy".

the xml source this:

<?xml version="1.0" encoding="utf-8" ?> <nodes>   <node>     <titel>the title here</titel>     <allterms>term1; term2</allterms>     <shorttext>&amp;lt;div&amp;gt;html text &amp;lt;/div&amp;gt;</shorttext>     <nid>3433333</nid>     <year>2015</year>   </node>   <node>     <titel>the title here</titel>     <allterms>term1; term2; energy</allterms>     <shorttext>&amp;lt;div&amp;gt;html text &amp;lt;/div&amp;gt;</shorttext>     <nid>2211338</nid>     <year>2014</year>   </node> </nodes> 

i want create same xml xslt new xml should have <node> <allterms> contains word "energy".

i found examples , tried them, not seem work:
- test="contains(allterms, 'energy')
- , match="nodes/node[contains(allterms, 'energy')]

a> how should xslt desired result?
b> use internet explorer xslt , 20 mb xml smaller filtered xml? or there better tool?

thanks!

use xslt stylesheet

<xsl:stylesheet   xmlns:xsl="http://www.w3.org/1999/xsl/transform"   version="1.0">  <xsl:template match="@* | node()">   <xsl:copy>     <xsl:apply-templates select="@* | node()"/>   </xsl:copy> </xsl:template>  <xsl:template match="node[not(contains(allterms, 'energy'))]"/>  </xsl:stylesheet> 

to use xslt transform xml xml suggest use xml ide or editor oxygen, stylus studio, altova xmlspy or xslt plugin favorite programming editor or ide or xslt processor can run command line.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -