INTest.rbs|INTest.rbs|TXT_P2P|MFH|3DES, with compression|192.168.3.252|192.168.3.1|170|3446429495|Tove|Jani|Reminder|Don't forget me this weekend!
INTest2.rbs|INTest2.rbs|TXT_IM|192.168.3.1|MTH|3DES, with compression|BBM_P2P|74|2339604654|Jack|JTove|Reminder|Ok
how i can filter thats xml like output...any one can explain using awk or sed
# convert into elements
xsltproc xml2elements.xsl example.xml > example.2.xml
# convert into csv, using default parameters
xsltproc xml2csv.xsl example.2.xml
# convert into csv, without column names
xsltproc -param colnames n xml2csv.xsl example.2.xml
# convert using delimiter | and without colnames
xsltproc -param colnames n -stringparam delim "|" xml2csv.xsl example.2.xml
I'm not xslt heavy user, found lot of examples and done those versions.
Sometimes also need to remove/flat/... before making csv. Here is some example to edit xml data.
remove.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<!-- default copy all node -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- template for the document element -->
<!-- = remove root node -->
<xsl:template match="/*">
<xsl:apply-templates select="node()" />
</xsl:template>
<!-- remove attributes <xxx attr="some">value</xxx> -->
<xsl:template match="@attr"/>
<xsl:template match="@format"/>
<xsl:template match="@author"/>
<!-- remove element <xxx>value</xxx> -->
<xsl:template match="xxx"/>
<xsl:template match="country"/>
<!-- remove only element childs <xxx><child1>val</child1></xxx> -->
<xsl:template match="xxx/*" />
<!-- move children element value for mother and remove child = more flat,
less hierarchical -->
<xsl:template match="subnode/*">
<xsl:apply-templates select="node()" />
</xsl:template>
<!-- remove some element but leave the child = more flat, less hierarchical -->
<xsl:template match="some">
<xsl:apply-templates select="node()" />
</xsl:template>
<!-- remove some data based on attribute value -->
<xsl:template match="product[@id='p6']" />
<!-- remove comments -->
<xsl:template match="comment()"/>
<!-- rename element name=>itemname -->
<xsl:template match="name">
<itemname>
<xsl:apply-templates select="@*|node()"/>
</itemname>
</xsl:template>
</xsl:stylesheet>
Or use keyword awk xml to search many example in this forum.