I need to parse text between xml tags using xsltproc. It seems the easiest way.
Here the Input file looks like
<?xml version="1.0" ?>
- <tag:ROOT xmlns:as="http://some.org/some.xsd" xmlns:tag="http://www.tag.org/schemas" xmlns:xs="http://some.org/">
- <tag:L1>
- <tag:L2>
- <tag:L3>
- <tag:L4>
- <tag:L5>
- <tag:L6>
- <tag:L7>
- <tag:DATA>
<tag:DataFlag>False</DataFlag>
<tag:DataName>Alex</tag:DataName>
<tag:DataContact>Phone1</tag:DataContact>
</tag:DATA>
- <tag:DATA>
<tag:DataFlag>False</DataFlag>
<tag:DataName>Mike</tag:DataName>
<tag:DataContact>Phone2</tag:DataContact>
</tag:DATA>
- <tag:DATA>
<tag:DataFlag>True</DataFlag>
<tag:DataName>Patty</tag:DataName>
<tag:DataContact>Phone3</tag:DataContact>
<tag:DataDesc>user active</tag:DataDesc>
</tag:DATA>
</tag:L7>
</tag:L6>
</tag:L5>
</tag:L4>
</tag:L3>
</tag:L2>
</tag:L1>
</tag:ROOT>
I need the output in a text file or a standard o/p as:
False Alex Phone1
False Mike Phone2
True Patty Phone3
The had tried below code block but it is giving error at line number 5.
Code I had written:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select=".//tag:ROOT/tag:L1/tag:L2/tag:L3/tag:L4/tag:L5/tag:L6/tag:L7/tag:DATA>
<xsl:value-of select=".//DataFlag"/>
<xsl:value-of select=".//DataName"/>
<xsl:value-of select=".//DataContact"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Can you please help parsing the attribute in a text OR may be a standard output?
---------- Post updated at 12:12 PM ---------- Previous update was at 10:23 AM ----------
Any help? Please?