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 8442051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:44:32+00:00 2026-06-10T08:44:32+00:00

Good Day, I have the following XML file: <?xml version=1.0 encoding=utf-8 ?> <company> <name>XYZ

  • 0

Good Day,

I have the following XML file:

<?xml version="1.0" encoding="utf-8" ?>
<company>
    <name>XYZ Inc.</name>
    <address1>One Abc Way</address1>
    <address2>Some avenue</address2>
    <city>Tech city</city>
    <country>Neverland</country>
    <products>
        <product id="123">Toaster</product>
        <product id="293">Oven</product>
        <product id="241">Egg Beater</product>
    </products>
</company>

and the following XSLT file:

<table>
    <xsl:for-each select="/company/products">
        <tr>
            <td>Product:</td>
            <td>
                <xsl:value-of select="product"/>
            </td>
        </tr>
    </xsl:for-each>
</table>

but when I run the following C# code:

        string xmlFile = Path.Combine(xmlFolder, "Company.xml");
        string xsltFile = Path.Combine(xsltFolder, "Company.xslt");
        string htmlOutputFile = Path.Combine(templateFolder, "Company.html");

        XPathDocument myXPathDoc = new XPathDocument(xmlFile);
        XslCompiledTransform myXslTrans = new XslCompiledTransform(true);
        myXslTrans.Load(xsltFile);

        XmlTextWriter myWriter = new XmlTextWriter(htmlOutputFile, null);
        myXslTrans.Transform(myXPathDoc, null, myWriter);

but when I open up the resulting HTML document, only the first product displays.

<table>
    <tr>
        <td>
            Product:
        </td>
        <td>
            Toaster
        </td>
    </tr>
</table>

Now, I’ve noticed if I used a “.” instead of product in the

<td><xsl:value-of select="."/>

Then I get all three values but on one line.

What am I missing?

TIA,

coson

  • 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-06-10T08:44:34+00:00Added an answer on June 10, 2026 at 8:44 am

    Your problem is that you’re doing for-each on products (which you have only one of). You probably meant something like this instead:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="/">
    
    <table>
        <xsl:for-each select="/company/products/product">
            <tr>
                <td>Product:</td>
                <td>
                    <xsl:value-of select="."/>
                </td>
            </tr>
        </xsl:for-each>
    </table>                    
    </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day everyone, I have the following XML data : <?xml version=1.0 encoding=utf-8 ?>
Good day I have a custom TextBox that has a IndicatorTextBox.ui.xml file as well
Good day everyone, I have an HTACCESS file that contains the following: Options +FollowSymlinks
Good Day, I am trying to query an XML document and have the following
Good day, I have the following problem: class B extends class A and methods
Good day to all, I have the following problem I have to convert the
Good day, If I have for example the documents which have the following fields
Good day all I have the following question: I would like to use Chart
Good day, i have following setup for my little service: -module(mrtask_net). -export([start/0, stop/0, listen/1]).
Hello and good day to all. I have the following code to retrieve from

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.