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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:50:53+00:00 2026-06-15T00:50:53+00:00

I want to create a html list () from an xml using xslt. I

  • 0

I want to create a html list () from an xml using xslt. I was able to do so with an xml file and a xslt file. Now I want to do it with an xml string or XmlDocument and and xslt file.

This is my current code:

private String toHTML(XmlDocument xmlDocument)
        {
            System.IO.StringWriter sw = new System.IO.StringWriter();
            XslCompiledTransform xslTrans = new XslCompiledTransform();
            xslTrans.Load(Server.MapPath("Xslt/Permisos.xslt"));
            xslTrans.Transform(xmlDocument.CreateNavigator(), new XsltArgumentList(), sw);
            return sw.ToString(); 
        }

It is on a single web application assembly.
No exception is thrown. Just returns “”.

My XSLT

 <?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="/">
        <xsl:for-each select="menus">
          <ul>
            <xsl:for-each select="menu">
              <li>
                <a href="{url}">
                  <xsl:value-of select="nombre" />
                </a>
                <ul>
                  <xsl:for-each select="submenu">
                    <li>
                      <a href="{url}">
                        <xsl:value-of select="nombre" />
                      </a>
                    </li>
                  </xsl:for-each>
                </ul>
              </li>
            </xsl:for-each>
          </ul>
        </xsl:for-each>
      </xsl:template>
    </xsl:stylesheet>

MY XML

<?xml version="1.0" encoding="UTF-8"?><menus xmlns="http://www.xxxxx.com"><menu><nombre>Main</nombre><url>#</url><submenu><nombre>Sub</nombre><url>#</url></submenu><submenu><nombre>Sub</nombre><url>#</url></submenu><submenu><nombre>Sub</nombre><url>#</url></submenu><submenu><nombre>Sub</nombre><url>#</url></submenu><submenu><nombre>Sub</nombre><url>#</url></submenu><submenu><nombre>Sub</nombre><url>#</url></submenu><submenu><nombre>Sub</nombre><url>#</url></submenu><submenu><nombre>Sub</nombre><url>#</url></submenu><submenu><nombre>Sub</nombre><url>#</url></submenu><submenu><nombre>Sub</nombre><url>#</url></submenu></menu></menus>

Thanks!

  • 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-15T00:50:54+00:00Added an answer on June 15, 2026 at 12:50 am

    As mentioned in another SO answer. The issue is that you define a namespace in your source XML (“http://www.xxxxx.com“) but you do not use the namespace in your xslt.

    You can either remove the namespace from the source XML or specify it in your xslt:

    <?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" 
      xmlns:my="http://www.xxxxx.com">
    
      <xsl:output method="html" indent="yes"/>
      <xsl:template match="/">
        <xsl:for-each select="my:menus">
          <ul>
            <xsl:for-each select="my:menu">
              <li>
                <a href="{my:url}">
                  <xsl:value-of select="my:nombre" />
                </a>
                <ul>
                  <xsl:for-each select="my:submenu">
                    <li>
                      <a href="{my:url}">
                        <xsl:value-of select="my:nombre" />
                      </a>
                    </li>
                  </xsl:for-each>
                </ul>
              </li>
            </xsl:for-each>
          </ul>
        </xsl:for-each>
      </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 want to create a ordered html list like this: 1.0 Introduction 1.1 Features
I am using this to get a list of elements from a webpage. http://www.gamespy.com/index/release.html
I want to create a html page that get data from a website table
I want to create a generic html table to excel file view that can
I want to create a multicolumn layout in html that will run from left
I want to create a non-stop spinning square using html and css. I currently
I am querying an HTML file with LINQ-to-XML. It looks something like this: <html>
I am trying to create various, standard HTML list styles from PHP arrays for
I want to create a html table with a 1pt black outer border and
For every comma inside a certain MYSQL row, I want to create x html

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.