html - Clean XHTML tags -


i required import xml piece of software, xml provided created different bit of software , sent myself. go through xml document , strip out cdata tags , have find , replace tags uppercase lowercase , remove strong tags or ol tags.

but have reorganise tags allow imported software, example:

<b>got text here<p/>more bold text</b>

this not import unless manually go in , change

<b>got text here</b><p/><b>more bold text</b>

i have looked @ htmltidy , other such tools strip out <p/> tag completely. in need of keeping data in original formatting, if there way this?

using xslt, can this:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"     version="1.0">      <xsl:output indent="no" omit-xml-declaration="yes"/>      <xsl:template match="node()|@*">         <xsl:copy>             <xsl:apply-templates select="node()|@*"/>         </xsl:copy>     </xsl:template>      <xsl:template match="b/text()">         <b>             <xsl:value-of select="."/>         </b>     </xsl:template>      <xsl:template match="b">         <xsl:apply-templates/>     </xsl:template>  </xsl:stylesheet> 

when applied input like

<b>got text here<p/>more bold text</b> 

outputs:

<b>got text here</b><p/><b>more bold text</b> 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -