PDA

View Full Version : How To Insert HTML in XML Doc


lisa4va
10-28-2009, 05:16 PM
Hi Guys,
I am thankful to have found CodingForums.com. There seems to be a ton of useful information that I find myself needing on a more constant basis.I am trying to familiarize myself with XML but I am having a recurring problem and any advice is greatly appreciated.

My site currently uses a third party shipping software to automate our customer communications. I would like to customize our shipping notification email to include an HTML table with images linked to our social media profiles.

I have added text and it displays fine but when adding the table the images display as attachments rather than in the table across the bottom of the email.

Which leads me to my question, how do I insert a piece of HTML code into an XML package? <XSL:?????



<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sw="http://www.interapptive.com/shipworks" extension-element-prefixes="sw">
<xsl:import href="System\Common" />

<xsl:output method="html" encoding="utf-8" />

<sw:settings>
<sw:preview>
<sw:count>1</sw:count>
</sw:preview>
<sw:email>
<sw:store id="1">
<sw:account>0</sw:account>
</sw:store>
<sw:default>
<sw:includeInMenu>True</sw:includeInMenu>
<sw:subject>Your Order {//Order/Number} Has Shipped</sw:subject>
</sw:default>
</sw:email>
<sw:general>
<sw:context>auto</sw:context>
</sw:general>
</sw:settings>

<xsl:template match="/">
<html>

<head>
<title>Shipment Notification</title>

<style>
body, td, table, div { font: 10pt Arial;}
</style>
</head>

<body>
<xsl:variable name="order" select="//Order[1]" />
<xsl:variable name="address" select="$order/Address[@type='bill']" />

<xsl:value-of select="$address/FirstName" />,

<p>
Your order <xsl:value-of select="$order/Number" /> has shipped and the tracking information is below. Thank you for your business!
</p>

<p>
<xsl:if test="count($order//Shipment[IsProcessed = 'true' and (not(.//Voided) or .//Voided != 'true')]) = 0">
<i>(No shipments)</i>
</xsl:if>

<xsl:for-each select="$order//Shipment[IsProcessed = 'true' and (not(.//Voided) or .//Voided != 'true') ]">
Shipped on <b><xsl:value-of select="sw:ToShortDate(ShippedDate)" /></b>
using <b><xsl:value-of select="ServiceUsed" /></b>: <b><xsl:call-template name="outputTrackingLink" /></b>
<br />
</xsl:for-each>

<br>
<p><font face="Arial">Tracking information will be available online 24 hours after receipt of this e-mail.<br>
</br><br>
</br>Tracking numbers beginning with a 1 may be tracked at <a href="http://www.ups.com" target="_blank">www.ups.com</a>
<br>Tracking numbers beginning with a 9 may be tracked at
<a href="http://www.usps.com" target="_blank">www.usps.com</a></br>
<br>Tracking numbers beginning with a 0 may be tracked at <a href="http://www.fedex.com" target="_blank">www.fedex.com</a></br>
<br>
<br>
</br>
Remember,
all items are 100% guaranteed! When your order arrives, if you are
dissatisfied for any reason please e-mail us at <a href="mailto:questions@championsond.com" target="_blank">questions@championsond.com</a> or call us toll-free at 1-866-000-0000. We'll
be happy to replace your order or give you a full refund if necessary.
We value your business and want the opportunity to earn it again!
</br>
<br><br>
</br>Don't
forget to become a Fan on
<a href="http://www.facebook.com/pages/Champions-On-D/64754010889?ref=ts">Facebook</a>
for a chance to win every Friday. and check out our blog,
<a href="http://www.championblog.com">www.championblog.com</a> for
product information and promos!</br>
<br><br>
</br>Thank you for your business!<br>
</br></br> Customer Support
<br><a href="http://www.championsond.com">www.championsond.com</a></br>
<br>1-866-000-0000</br>
</font>
</p>
</br>
</p>
</body>
</html>

</xsl:template>
</xsl:stylesheet>


How do I insert the following code to display across the bottom rather than as attachments? And is there a "universal" way of adding simple code to XML?

<table width="557" align="center" cellpadding="0">
<tr>
<td width="195"><div align="center"><a href="http://www.facebook.com/home.php?#/pages/Champions-On-D/64754010889"><img src="http://www.championsond.com/skins/Skin_1/images/logos/fb.jpg" width="167" height="53" border="0"></a></div></td>
<td width="180"><div align="center"><a href="http://www.championblog.com"><img src="http://www.championsond.com/skins/Skin_1/images/social_blog.jpg" width="170" height="70" border="0"></a></div></td>
<td width="190"><div align="center"><a href="http://www.twitter.com/ChOnD"><img src="http://www.championsond.com/skins/Skin_1/images/twitter.jpg" width="153" height="36" border="0"></a></div></td>
</tr>
</table>


Thanks for any help!

Lisa4va

oesxyl
10-28-2009, 06:30 PM
add the html namespace http://www.w3.org/1999/xhtml as default namespace or using a qname then write the html as usual, that means without any prefix if is default namespace or with the prefix you declare.

best regards

rnd me
10-29-2009, 02:35 AM
most email apps block images for security reasons.

simply viewing an email with <img src="http://hackersite.com/checkin.php?id=2343" />

will confirm to hackersite that spam #2343 was sent to a valid email address, and that the person got the message...

you can send them a link to a page where the table can be viewed, or turn the entire table into an attached image, your choice.

the other snag is that your html is not valid xml, so it would break your whole file if it were included.
<img src="..." width="153" height="36" border="0">
should be:
<img src="..." width="153" height="36" border="0" />

lisa4va
11-03-2009, 07:35 PM
Thanks for your replies.
most email apps block images for security reasons.

simply viewing an email with <img src="http://hackersite.com/checkin.php?id=2343" />

will confirm to hackersite that spam #2343 was sent to a valid email address, and that the person got the message...

you can send them a link to a page where the table can be viewed, or turn the entire table into an attached image, your choice.

the other snag is that your html is not valid xml, so it would break your whole file if it were included.

rnd me - I understand that most images are blocked but would still like to add links to our social profiles. I just added these in a table for the purpose of displaying straight across the bottom.

The code IS currently inserted in the xml file and doesnt break it but just displays the images as attachments rather than part of the email body. I assume this is because its not valid xml - so maybe I should be asking how I can turn this piece of code into valid xml? Is there a way to write xml out of this code? By doing so would this then fix the display issue or are you saying that images can't be added to xml at all due to the email apps blocking? I would even settle for the blank box with a red x in it until they opted to display images if neccessary, as long as its part of the body and not an attachment.

Thanks again for your reply - and the tip on the missing / .

rnd me
11-03-2009, 11:13 PM
so maybe I should be asking how I can turn this piece of code into valid xml? Is there a way to write xml out of this code? By doing so would this then fix the display issue or are you saying that images can't be added to xml at all due to the email apps blocking?

let me put it this way: <img> tag's won't display in the body of an email.
it doesn't have anything to do with XML, and there's nothing you can do to change the rules. Sorry to disappoint.

You can make a table into an image by using 1px high rows, thousands of cells, and lots of bgcolor attribs. But it's a total waste of space; a 100X100 image would take at least a megabyte of space as a table...