If you can use XSLT 2.0 you could use unparsed-text()
...
Text File (Do not use the text file as direct input to the XSLT.)
!ITEM_NAME
Item value
!ANOTHER_ITEM
Its value
!TEST_BANG
Here's a value with !bangs!!!
XSLT 2.0 (Apply this XSLT to itself (use the stylesheet as the XML input). You'll also have to change the path to your text file. You might have to change the encoding too.)
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="text-encoding" as="xs:string" select="'iso-8859-1'"/>
<xsl:param name="text-uri" as="xs:string" select="'file:///C:/Users/dhaley/Desktop/test.txt'"/>
<xsl:template name="text2xml">
<xsl:variable name="text" select="unparsed-text($text-uri, $text-encoding)"/>
<xsl:analyze-string select="$text" regex="!(.*)
(.*)">
<xsl:matching-substring>
<xsl:element name="{normalize-space(regex-group(1))}">
<xsl:value-of select="normalize-space(regex-group(2))"/>
</xsl:element>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template match="/">
<document>
<xsl:choose>
<xsl:when test="unparsed-text-available($text-uri, $text-encoding)">
<xsl:call-template name="text2xml"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="error">
<xsl:text>Error reading "</xsl:text>
<xsl:value-of select="$text-uri"/>
<xsl:text>" (encoding "</xsl:text>
<xsl:value-of select="$text-encoding"/>
<xsl:text>").</xsl:text>
</xsl:variable>
<xsl:message><xsl:value-of select="$error"/></xsl:message>
<xsl:value-of select="$error"/>
</xsl:otherwise>
</xsl:choose>
</document>
</xsl:template>
</xsl:stylesheet>
XML Output
<document>
<ITEM_NAME>Item value</ITEM_NAME>
<ANOTHER_ITEM>Its value</ANOTHER_ITEM>
<TEST_BANG>Here's a value with !bangs!!!</TEST_BANG>
</document>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…