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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:20:19+00:00 2026-06-09T08:20:19+00:00

This should be simple and everything I read says that select = name should

  • 0

This should be simple and everything I read says that select = “name” should select all the nodes with the “name” in an xml document..
So Im trying to work a simple example.. here’s the XML: (its a simple inventory app).

<?xml version="1.0"?>
<inventory type="inventory">
<item type="zone" CanAdd="true">
    <title>Building</title>
    <item type="porch" CanAdd="true">
        <title>Porch</title>
    </item>
    <item type="receptionRoom" CanAdd="true">
        <title>Reception Room</title>
        <item type="doorInfo" CanAdd="true">
            <title>Door</title>
            <item type="doorStyleType" select="multi">
                <title>Door Style</title>
                <item>
                    <title>Internal</title>
                </item>
                <item>
                    <title>Plain</title>
                </item>
            </item>
            <item type="doorWinMaterialType" select="single">
                <title>Door Material</title>
                <item type="softwoodColours" select="single">
                    <title>Softwood - Stained</title>
                    <item>
                        <title>Stained Pine</title>
                    </item>
                </item>
            </item>
            <item type="doorwinFurnitureType" select="multi">
                <title>Door Furniture</title>
                <item>
                    <title>Door Handle</title>
                </item>
                <item>
                    <title>LetterBox Opening</title>
                </item>
            </item>
        </item>
    </item>
</item>
<propertyName><![CDATA[2 Street, Village]]></propertyName>
<propertyRef><![CDATA[15p9]]></propertyRef>
</inventory>

.. and I need to start to process it with XSLT. (In a C# code behind page – that bit works and throws the result into a pop up.)

The XSLT I am playing with is:

<?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:xs="http://www.w3.org/2001/XMLSchema"
            >
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
    <div>
            <h2>My Inventory</h2>
            <table border="1">
                <tr>
                    <td>
                    <xsl:value-of select="inventory/propertyName" />
                    </td>
                </tr>
            <xsl:for-each select ="item">
                <tr>
                    <td>
                        <xsl:value-of select="."/>
                    </td>  
                </tr>
            </xsl:for-each>
            </table>
        <p>Hello world</p>
   </div>
</xsl:template>
</xsl:stylsheet>

The “item” node is not found in the for-each loop and I think I’ve hit a mental block as to why. I’m sure the answer is glaringly simple when you know it, but at the moment I don’t and need to solve this before I can move on so to speak.
The output is: (in a browser)..

My Inventory
2 Street, Village 
(I expect a list of the "item" node values here in table rows..)
Hello world

Many Thanks,
Brett

  • 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-09T08:20:21+00:00Added an answer on June 9, 2026 at 8:20 am

    The XPath item that you’ve specified for your <xsl:for-each> loop is evaluated relative to the current node, i.e. relative to the document root. In order to select any <item> elements at any nesting depth in the document, you will have to use

    //item
    

    However, I think you want something slightly different, as the text of <item> elements themselves is their <title> text as well as the text of any nested <item> elements. Possibly, you are looking for:

    //item/title
    

    To respond directly to your sentence

    everything I read says that select = “name” should select all the nodes with the “name” in an xml document

    This is not correct. select="name" selects all the elements named “name” in the list of child nodes of the current node, not anywhere in the Xml document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be simple, yet I can't get it to work. I have a
From everything I've read, it seemed that adding paging to a ListView control should
This should be simple, but I'm getting confused. I have a parent/child tables -
This should be simple task but i am not been able to find the
This should be simple, but the answer is eluding me. If I've got a
This should seem simple enough, but can't figure it out. I was porting a
This should be simple, but I am still lost. There is a very similar
Hey guys this should be simple, I'm just not seeing it, I would like
Seems like this should be simple, but powershell is winning another battle with me.
I think this should be simple but I am having some difficulty implementing it.

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.