add same namespace to xml using xsl

Justah

New Member
\[code\]<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t1="http://mynamespace/A" xmlns:top="http://mynamespace/B" xmlns:max="http://mynamespace/C"><soapenv:Body> <t1:Creditcard> <top:AutoPayenroll> <top:CustomerId> <max:CustName>Taylor</max:CustName> <max:CustID>1234</max:CustID> </top:CustomerId> </top:AutoPayenroll> </t1:CreditCard></soapenv:Body></soapenv:Envelope> \[/code\]Need to change the CustID to encrypted one which I did. but dont know how to insert itUsed this XSL:\[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t1="http://mynamespace/A" xmlns:top="http://mynamespace/B" xmlns:max="http://mynamespace/C" version="1.0"> <xsl:output method="xml"/><xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="//*[local-name()='CustID']"> <xsl:variable name="cleartxt" select="./text()"/> <!--got this encrypted data from my internal code--> <xsl:variable name="encdata" select="'jksdguasidgeiruh'"/> <xsl:element name="//*[local-name()='Pswd']"> <xsl:value-of select="$encdata"/> </xsl:element> </xsl:template> <xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet> \[/code\]Response should be as follows: \[code\]<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t1="http://mynamespace/A" xmlns:top="http://mynamespace/B" xmlns:max="http://mynamespace/C"><soapenv:Body> <t1:Creditcard> <top:AutoPayenroll> <top:CustomerId> <max:CustName>Taylor</max:CustName> <max:CustID>jksdguasidgeiruh</max:CustID> </top:CustomerId> </top:AutoPayenroll> </t1:CreditCard></soapenv:Body></soapenv:Envelope> \[/code\]
 
Back
Top