Ich verwende für solche Geschichten immer xsltproc
PHP-Code:
< ? xml version = '1.0' encoding = 'utf-8' ? >
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:reg="http://exslt.org/strings"
extension-element-prefixes="reg">
<!-- Undefined http://www.hjcms.de, (C) 2007-2010 -->
<xsl:output version="1.0"
method="xml"
encoding="utf-8"
indent="yes"
media-type="application/xhtml+xml"
doctype-system = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public = "-//W3C//DTD XHTML 1.0 Transitional//EN"
/>
<xsl:template match="*" mode="txt">
<xsl:variable name="tmp1" select="reg:replace(text(),'ä','ae')" />
<xsl:variable name="tmp2" select="reg:replace($tmp1,'ö','oe')" />
<xsl:variable name="tmp3" select="reg:replace($tmp2,'ü','ue')" />
<xsl:value-of select="$tmp3" />
<xsl:apply-templates select="*" mode="html" />
</xsl:template>
<!-- Copy -->
<xsl:template match="*" mode="html">
<xsl:element name="{name()}">
<xsl:for-each select="@*">
<xsl:attribute name="{name()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:for-each>
<xsl:choose>
<xsl:when test="text()">
<xsl:apply-templates select="." mode="txt" />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="./*" mode="html" />
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<!-- Main -->
<xsl:template match="/">
<xsl:apply-templates select="./*" mode="html" />
</xsl:template>
</xsl:stylesheet>
Code:
xsltproc --output out.html strip2ascii.xslt input.html
Lesezeichen