Hello! Faced the task that you need to convert xml to txt and back, using xslt. Wrote xslt code that converts xml to txt. Txt with structure [tag] _ field.

I attach the xsl code

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:output method="text"/> <xsl:strip-space elements="*"/> <xsl:template match="*"> <xsl:value-of select="concat(name(), ' ')"/> <xsl:apply-templates select="node()|@*"/> <!-- Инструкция xsl:if позволяет создавать простые условия типа "если-то".--> <xsl:if test="position()!= last()" > <xsl:text> </xsl:text> </xsl:if> </xsl:template> </xsl:stylesheet> 

txt, for example, looks like this:

  country RUS town Moscow address 20, Zeleniy prospectus и т.д. 

The task is to write an xslt txt-xml converter. Before that, I did not work with this.

  • The inverse problem has no solution. XSLT works only with XML documents. And the XML document contains at least one root node - Anton Shchyrov
  • What tool can convert txt to xml? - MarSha
  • For example, this is '<root><![CDATA[' + content + ']]></root>' . If the encoding is not utf-8, then add the prologue as well - Anton Shchyrov

0