Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7682315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:32:23+00:00 2026-05-31T18:32:23+00:00

I have an XML document containing contact information as seen below: <contact type=individual> <firstname>Some</firstname>

  • 0

I have an XML document containing contact information as seen below:

<contact type="individual">
    <firstname>Some</firstname>
    <surname>Guy</surname>
    <organisation>
        <name>London School of Espionage</name>
    </organisation>
    <address>
        <line1>Houghton St</line1>
        <cityortown>London</cityortown>
        <postalcode>WC2A 2AE</postalcode>
        <country>UK</country>
        </address>
    <telephone prefix="+44" type="work">
        <areacode>020</areacode>
        <number>71239876</number>
    </telephone>
    <telephone prefix="+44" type="mobile">
        <areacode>07123</areacode>
        <number>543098</number>
    </telephone>
    <email type="work">gorgeousgeorge@lse.ac.uk</email>  
    <email type="personal">george123@gmail.com</email>
    <fax prefix="+44" type="work">
        <areacode>020</areacode>
        <number>78001234</number>
    </fax>
    <website>www.espionage.co.uk</website>
</contact

>

I have an XSL template which should show all the information in a table, but only the first email address is displaying. Please could someone advise on what I’m doing wrong:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="contacts.css"/>
    </head>
    <body>

        <div id="main">
    <h1 align="center">XML Contact Book</h1>
    <table>
        <tr><th>Name</th>
        <th>Organisation</th>
        <th>Address</th>
        <th>Email</th>
        <th>Telephone</th>
        <th>Fax</th>
        <th>Website</th></tr>
        <xsl:for-each select="contacts/contact/.">
            <tr>
                <td valign="bottom"><xsl:value-of select="firstname"/>&#160;<xsl:value-of select="surname"/></td>
                <td valign="bottom"><xsl:value-of select="organisation/name"/></td>
                <td valign="bottom" width="200px"><xsl:value-of select="address/line1"/><br/>
                    <xsl:value-of select="address/line2"/><br/>
                    <xsl:value-of select="address/line3"/><br/>
                    <xsl:value-of select="address/cityortown"/><br/>
                    <xsl:value-of select="address/countyorstate"/><br/>
                    <xsl:value-of select="address/postalcode"/><br/>
                    <xsl:value-of select="address/country"/><br/></td>
                <!--creates a mailto: link for the email address contained in contacts.xml-->
                <td valign="bottom"><a><xsl:attribute name="href">mailto:<xsl:value-of select="email"/></xsl:attribute><xsl:value-of select="email"/></a>
                    <br/><p><xsl:value-of select="email/@type"/>&#160;email</p></td>
                <td valign="bottom"><p>Prefix: <xsl:value-of select="telephone/@prefix"/></p> <xsl:value-of select="telephone/areacode"/>&#160;<xsl:value-of select="telephone/number"/></td>
                <td valign="bottom"><p>Prefix: <xsl:value-of select="fax/@prefix"/></p><xsl:value-of select="fax/areacode"/>&#160;<xsl:value-of select="fax/number"/></td>
                <!--creates hyperlink to website listed in contact details-->
                <td valign="bottom"><a><xsl:attribute name="href">http://<xsl:value-of select="website"/></xsl:attribute><xsl:value-of select="website"/></a></td>
            <hr/>
            </tr>
        </xsl:for-each>

    </table>

        </div>
    </body>
</html>
</xsl:template>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:32:24+00:00Added an answer on May 31, 2026 at 6:32 pm
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="/contacts">
        <table>
            <!-- apply templates to each contact -->
                <xsl:apply-templates select="contact"/>
        </table>
    </xsl:template>
    
    <xsl:template match="contact">
        <tr>
            <!-- apply templates as required -->
            <td>
                <xsl:apply-templates select="firstname"/>
            </td>
            <td>
                <xsl:apply-templates select="email"/>
            </td>
        </tr>
    </xsl:template>
    
    <!-- email template -->
        <xsl:template match="email">
                <a href="mailto:{.}"><xsl:value-of select="."/></a>
        </xsl:template>
    
        <!-- add other templates, example -->
        <xsl:template match="firstname">
                <xsl:value-of select="concat(.,'&#160;',following-sibling::surname)"/>
        </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string containing XML document using LinqtoXML What is the best way
Have a source xml document that uses namespace containing prefixes and a default namespace.
I have an XML document that looks like this <Elements> <Element> <DisplayName /> <Type
I have a simple XML document containing two city id's. <?xml version=1.0 encoding=ISO-8859-1?> <config>
I have an XML document with a node containing the escaped XML serialization of
I have this XML document <AdditionalParameters> <PublishToPdf Type =System.Boolean>False</PublishToPdf> </AdditionalParameters> in my code and
I have tons of XML files all containing a the same XML Document, but
Background: We have an XML document containing thousands of pseudocode functions. I've written a
I have an XML document with a bunch of elements, each containing a timestamp
I have an XML document containing types from 2 XML schemas. One (theirs.xsd) is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.