Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert XML email to regular email (in table form)

Status
Not open for further replies.

wacks

Programmer
Sep 10, 2001
58
US
hi. i am an XML newbie.... anybody knows a code or a tool to convert XML emails to regular email?

if i received something like:

<Name1> John </Name1>
<Address1> 123 Broadway Ave </Address1>
<City1> Los Angeles </City1>

<Name2> Jane </Name2>
<Address2> 321 Manhattan Blvd <Address2>
<City2> New York </City2>


I want my email to look like this: (in table form)

Name Address City
John 123 Broadway Ave Los Angeles
Jane 321 Manhattan Blvd New York


anyone? i appreciate your help.


thanks

vipersig.jpg
 
It is unwise to invent tagname each time they have a new address/mail. Reject what you receive and ask them to prepare consistent xml file.
 
With each time a new element/tag name for each entry, you are forced to make some positional reference avoiding the name. Suppose it is of this structure per your post---[blue]but, I repeat using Name1, Name2 etc is no good at all[/blue].
[tt]
<root>
<mail>
<Name1>...</Name1>
<Address1>...</Address1>
<City1>...</City1>
</mail>
<mail>
<Name2>...</Name2>
<Address2>...</Address2>
<City2>...</City2>
</mail>
...
</root>
[/tt]
You can do something like this and as raw.
[tt]
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:eek:utput method="html" />
<xsl:template match="/">
<table border="1">
<tr>
<td>Name</td>
<td>Address</td>
<td>City</td>
</tr>
<xsl:apply-templates select="root/mail" />
</table>
</xsl:template>
<xsl:template match="root/mail">
<tr>
<xsl:for-each select="child::*[position()&lt;4]">
<td><xsl:value-of select="." /></td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top