www.webdeveloper.com
Results 1 to 8 of 8

Thread: Rename tag in xml

  1. #1
    Join Date
    Jan 2010
    Posts
    8

    Rename tag in xml

    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.

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Just what tools do you have at your disposal. Xalan? Saxon? MSXML? PHP? Perl?
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Jan 2010
    Posts
    8
    I am using xmlspy

  4. #4
    Join Date
    Nov 2002
    Location
    England
    Posts
    693
    Using XSL:

    HTML Code:
    <?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>

  5. #5
    Join Date
    Jan 2010
    Posts
    8
    Works very well - thanks!

  6. #6
    Join Date
    Nov 2002
    Location
    England
    Posts
    693
    No problem.

  7. #7
    Join Date
    Jan 2010
    Posts
    8
    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!

  8. #8
    Join Date
    Jan 2010
    Posts
    8

    One issue left to resolve

    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?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles