Prabodh Bansal

Prabodh Bansal

  • NA
  • 51
  • 1.2k

Convert XSLT string to xml string in c#.net

Jan 16 2019 12:56 AM
Following is string and i want to convert to xml string 
 
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/root">
<tbody>
<tr>
<td align="center">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="toppadding" height="40" ></td>
</tr>
<tr>
<td class="headline" style="padding-bottom:25px;">
<font size="5" face="Arial" color="#000">
<b>YOUR ORDER HAS BEEN SHIPPED</b>
</font>
</td>
</tr>
<tr>
<td class="headpadding" height="20" ></td>
</tr>
<tr>
<td >
<font class="subhead" size="2" face="Arial">
Hi <xsl:value-of select="shippingAddress/firstName"/> <xsl:value-of select="shippingAddress/lastName"/>
</font>
</td>
</tr>
<tr>
<td class="subpadding" height="20" ></td>
</tr>
<tr>
</tr>
<tr>
<td class="standardpadding" height="20" ></td>
</tr>
<tr>
<td class="topText" style="padding-bottom:20px; color:#000; text-decoration:none;">
<xsl:variable name="orderId" select="id" />
<font class="maintext" size="2" face="Arial">
Good news! We have just shipped your Bang &amp; Olufsen order - and it is on the way to you right now.<br/>
<br/>
For a detailed overview of your order click <a href="http://www.bang-olufsen.com/en/checkout/orderdetails?order={$orderId}">here</a>. If you paid by credit card, the card has now been charged. <br/>
<br/>
Please save this email for your records. Below is your purchase and shipping information.<br/>
<br/>
</font>
</td>
</tr>
<tr>
<td class="standardpadding" height="20" ></td>
</tr>
<tr>
<td>
<table width="600" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">
<tbody>
<tr style="line-height:4px; mso-line-height-alt:0; mso-margin-top-alt:1px;">
<td bgcolor="#c0c0c0" height="1" colspan="4"> </td>
</tr>
<tr>
<td colspan="4" >
<font class="tablehead" face="Arial" size="5" color="#000" line-height="35px">
<br />
<b>Your order:</b>
</font>
</td>
</tr>
<tr>
<td class="orderLabels" colspan="4" style="padding-bottom:20px;">
<font class="maintext" face="Arial" size="2">
<br />
Order number:
<xsl:value-of select="orderNumber" />
<br />
Order date:
<xsl:value-of select="createdAt"/>
<br />
<br />
</font>
</td>
</tr>
<tr>
<td class="productSpecs" style="padding-bottom:20px;">
<font class="maintext" face="Arial" size="2" color="#000">
<b>Product SKU</b>
</font>
</td>
<td class="productSpecs" style="padding-bottom:20px;">
<font class="maintext" face="Arial" size="2" color="#000">
<b>Product name</b>
</font>
</td>
<td class="productSpecs" style="padding-bottom:20px;">
<font class="maintext" face="Arial" size="2" color="#000">
<b>Quantity</b>
</font>
</td>
<td class="productSpecs tdAlign" style="text-align: left; padding-bottom:20px; padding-left:40px;">
<font class="maintext" face="Arial" size="2" color="#000">
<b>Amount</b>
</font>
</td>
</tr>
<xsl:for-each select="lineItems">
<tr>
<td >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="variant/sku"/>
</font>
</td>
<td >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="name/en-GB"/>
<xsl:value-of select="name/en"/>
</font>
</td>
<td >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="quantity"/>
</font>
</td>
<td class="tdAlign" style="text-align: left; padding-left:40px;">
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="price/value/currencyCode"/> <xsl:value-of select="format-number(price/value/centAmount div 100,'#.00')"/>
</font>
</td>
</tr>
</xsl:for-each>
<tr>
<td colspan="4">
<br />
</td>
</tr>
<tr>
<td class="subTotalPadding" style="padding-top:60px">
<font class="maintext" face="Arial" size="2" color="#000">Subtotal:</font>
</td>
<td></td>
<td></td>
<td class="tdAlign subTotalPadding" style="text-align:left; padding-top:60px; padding-left:40px;">
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="totalPrice/currencyCode"/> <xsl:value-of select="format-number(totalPrice/centAmount div 100,'#.00')"/>
</font>
</td>
</tr>
<tr>
<td >
<font class="maintext" face="Arial" size="2" color="#000">Shipping:</font>
</td>
<td></td>
<td></td>
<td class="tdAlign" style="text-align:left; padding-left:40px;">
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="shippingRate/currencyCode"/> 0
</font>
</td>
</tr>
<tr>
<td>
<font class="maintext" face="Arial" size="2" color="#000"></font>
</td>
<td>
<font class="maintext" face="Arial" size="2" color="#000"></font>
</td>
</tr>
<tr>
<td class="standardpadding" height="20" ></td>
</tr>
<tr style="line-height:0; mso-line-height-alt:0; mso-margin-top-alt:1px;">
<td colspan="4" bgcolor="#c0c0c0" height="1" > </td>
</tr>
<tr>
<td style="padding-top: 20px;">
<font class="maintext" face="Arial" size="2" color="#000">
<b>Total:</b>
</font>
</td>
<td></td>
<td></td>
<td class="tdAlign taxPadding" style="padding-left: 40px; text-align:left">
<font class="maintext" face="Arial" size="2" color="#000">
<b>
<xsl:value-of select="totalPrice/currencyCode"/> <xsl:value-of select="format-number(taxedPrice/totalGross/centAmount div 100,'#.00')"/>
</b>
</font>
<br />
</td>
</tr>
<tr>
<td class="taxPadding" style="padding: 0px;">
<font class="maintext" face="Arial" size="2" color="#000">Tax:</font>
</td>
<td></td>
<td></td>
<td class="tdAlign" style="padding-left: 40px; text-align:left">
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="totalPrice/currencyCode"/> <xsl:value-of select="format-number((taxedPrice/totalGross/centAmount - taxedPrice/totalNet/centAmount) div 100,'#.00')"/>
</font>
</td>
</tr>
<tr>
<td colspan="4" class="standardpadding" height="20" ></td>
</tr>
<tr style="line-height:0; mso-line-height-alt:0; mso-margin-top-alt:1px;">
<td colspan="4" bgcolor="#c0c0c0" height="1" > </td>
</tr>
<tr>
<td class="shippedBilledPadding" colspan="2" style="padding-top:40px; padding-bottom:20px;">
<font class="shippedBilledToLabel" face="Arial" size="2" color="#000">
<br />
<b>Shipped to:</b>
<br />
</font>
</td>
<td class="shippedBilledPadding" colspan="2" style="padding-top:40px; padding-bottom:20px;">
<font class="shippedToLabel shippedBilledToLabel" face="Arial" size="2" color="#000">
<br />
<b>Billed to:</b>
<br />
</font>
</td>
</tr>
<tr>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="shippingAddress/firstName"/>
<br/>
<xsl:value-of select="shippingAddress/lastName"/>
</font>
</td>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="billingAddress/firstName"/>
<br/>
<xsl:value-of select="billingAddress/lastName"/>
</font>
</td>
</tr>
<tr>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="shippingAddress/streetName"/>
</font>
</td>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="billingAddress/streetName"/>
</font>
</td>
</tr>
<tr>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
</font>
</td>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
</font>
</td>
</tr>
<tr>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="shippingAddress/additionalStreetInfo"/>
<br/>
<xsl:value-of select="shippingAddress/postalCode"/>
</font>
</td>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="billingAddress/additionalStreetInfo"/>
<br/>
<xsl:value-of select="billingAddress/postalCode"/>
</font>
</td>
</tr>
<tr>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="shippingAddress/city"/>
<br/>
<xsl:value-of select="shippingAddress/state"/>
<br/>
<xsl:value-of select="shippingAddress/country"/>
</font>
</td>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="billingAddress/city"/>
<br/>
<xsl:value-of select="billingAddress/state"/>
<br/>
<xsl:value-of select="billingAddress/country"/>
</font>
</td>
</tr>
<tr>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="shippingAddress/postalCode"/>
<br/>
<xsl:value-of select="shippingAddress/phone"/>
</font>
</td>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="billingAddress/postalCode"/>
<br/>
<xsl:value-of select="billingAddress/phone"/>
</font>
</td>
</tr>
<tr>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<b></b>
</font>
</td>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<b></b>
</font>
</td>
</tr>
<tr>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="shippingAddress/email"/>
</font>
</td>
<td colspan="2" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:value-of select="billingAddress/email"/>
</font>
</td>
</tr>
<tr>
<td class="botBorderPadding" colspan="4" style="padding-top:40px;"></td>
</tr>
<tr style="line-height:4px; mso-line-height-alt:0; mso-margin-top-alt:1px;">
<td colspan="4" bgcolor="#c0c0c0" height="1" > </td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td >
<table width="600" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">
<tbody>
<tr>
<td colspan="4" >
<font class="tablehead" face="Arial" size="2" color="#000">
<br></br>
<b>Track Your Order</b>
<br></br>
<br></br>
</font>
</td>
</tr>
<tr>
<td colspan="4" >
<font class="maintext" face="Arial" size="2" color="#000">
<xsl:variable name="trackingUrl" select="trackingUrl" />
<b>
<a href="{trackingUrl}" target="_blank" >
<xsl:value-of select="trackingId" />
</a>
</b>
</font>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="standardpadding" height="20" ></td>
</tr>
<tr>
</tr>
<tr>
<td class="standardpadding" height="20" ></td>
</tr>
<tr>
<td class="topText" style="padding-bottom:20px; color:#000; text-decoration:none;">
<font class="maintext" size="2" face="Arial">
<strong>While you are waiting for your Bang &amp; Olufsen products to arrive.</strong>
<br/>
<br/>
Sign up to our newsletter to get all the relevant stories from the Bang &amp; Olufsen universe. The newsletter includes new software and feature updates as well as exciting news on product launches and the people we collaborate with. Sign up here: <a href="https://www.bang-olufsen.com/en/newsletter">www.bang-olufsen.com/newsletter</a><br/>
<br/>
For a more in-depth look at Bang &amp; Olufsen go to our Journal, where we bring you tips and tricks on how to get the best out of the products – along with background stories on our designers and projects. You will also find our different playlists at the Journal – if you’re in need of music inspiration for your new Bang &amp; Olufsen product. Visit the Journal here: at <a href="http://www.beoplay.com/journal">www.beoplay.com/journal</a>.<br/>
<br/>
<p>
We hope that you will love your new Bang &amp; Olufsen product(s)! Again, if you have any questions or comments – feel free to contact us: <a href="http://www.beoplay.com/~/link.aspx?_id=87EA7959E0EB4D3EA62B643F6F2B1A1D&amp;_z=z">www.beoplay.com/contact-us</a>.
</p>
<p> </p>
All the best,<br/>
<strong>The Bang &amp; Olufsen team</strong>
<br/>
<br/>
Please do not reply to this email. If you need to contact Bang &amp; Olufsen, please <a href="http://www.beoplay.com/contact-us">click here</a>.
</font>
</td>
</tr>
<tr>
<td class="standardpadding" height="20" ></td>
</tr>
<tr>
<td class="bottompadding" height="10" ></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</xsl:template>
</xsl:stylesheet>
 
Regards
Mohan
 

Answers (1)