Click to See Complete Forum and Search --> : Rename tag in xml
longman111
01-12-2010, 01:08 PM
I need help with the syntax for finding a tag in a given xml file in order to rename it. An example of the tag is <AMLEntry SectionNumber="0"> which I want to rename to <AMLEntry>. I am a novice at xml so any help would be appreciated.
Charles
01-13-2010, 08:46 AM
Just what tools do you have at your disposal. Xalan? Saxon? MSXML? PHP? Perl?
longman111
01-13-2010, 10:27 AM
I am using xmlspy
Scriptage
01-13-2010, 12:32 PM
Using XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
encoding="ISO-8859-1"
media-type="text/xml" />
<xsl:template match="*">
<xsl:copy> <xsl:apply-templates/> </xsl:copy>
</xsl:template>
<xsl:template match="AMLEntry">
<AMLEntry>
<xsl:copy-of select="@SectionNumber[not(.='0')]|node()"/>
</AMLEntry>
</xsl:template>
</xsl:stylesheet>
longman111
01-13-2010, 06:21 PM
Works very well - thanks!
Scriptage
01-14-2010, 08:35 AM
No problem.
longman111
01-15-2010, 11:06 AM
One other problem. I can rename an element such as <kevin> to <joe> but I am having syntax issues with renaming <kevin> to <kevin ProcessType="">
Thanks for any help!
longman111
01-18-2010, 09:07 AM
I submitted my converted xml file on Friday and it was approved by the 3rd party vendor with one exception - I need the following line removed.
<Report xmlns="urn:crystal-reports:schemas">
Any suggestions?