I have the following xml source file :

<root>
<child1></child1>
<child2></child2>
</root>

I would like to convert it to

<MYOWNTAG1>
<CURRENTDATE>CurrentDate</CURRENTDATE>
<CURRENTTIME>CurrentTime</CURRENTTIME>
</MYOWNTAG1>

<MYOWNTAG2>
<XML> 
<root>
<child1></child1>
<child2></child2>
</root>
<XML>
</MYOWNTAG2>

Any help would is appreciated.

this is only possible with xsl parser support EXSLT
not so microsoft products

better not use xml tag as name

xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:datetime="http://exslt.org/dates-and-times" exclude-result-prefixes="datetime">
	<xsl:output indent="yes" method="xml"/>
	<xsl:template match="/">
		<MYOWNTAG1>
			<xsl:variable name="dateandtime">
				<xsl:value-of select="datetime:dateTime()"/>
			</xsl:variable>
			<CURRENTDATE>
				<xsl:value-of select="substring-before($dateandtime,'T')"/>
			</CURRENTDATE>
			<CURRENTTIME>
				<xsl:value-of select="substring-after(substring-before($dateandtime,'+'),'T')"/>
			</CURRENTTIME>
		</MYOWNTAG1>
		<MYOWNTAG2>
			<Data id="xml">
				<root>
					<xsl:apply-templates/>
				</root>
			</Data>
		</MYOWNTAG2>
	</xsl:template>
	<xsl:template match="date"/>
	<xsl:template match="child1">
		<child1>
			<xsl:value-of select="."/>
		</child1>
	</xsl:template>
	<xsl:template match="child2">
		<child2>
			<xsl:value-of select="."/>
		</child2>
	</xsl:template>
</xsl:stylesheet>

result

<?xml version='1.0' ?>
<MYOWNTAG1>
  <CURRENTDATE>2011-06-05</CURRENTDATE>
  <CURRENTTIME>15:03:35.745</CURRENTTIME>
</MYOWNTAG1>
<MYOWNTAG2>
  <Data id="xml">
    <root>
	
	
      <child1/>
	
      <child2/>

    </root>
  </Data>
</MYOWNTAG2>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.