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

  • Home
  • SEARCH
  • 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 6961737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:34:10+00:00 2026-05-27T15:34:10+00:00

I have a question on how to access the nodes from the XML using

  • 0

I have a question on how to access the nodes from the XML using XSL.

I have a xml like this:

<Table>
<Row>
   <Cell Type="Main" Id="980">Test22</Cell>
   <Cell Type="SubElement">Test22 Sub Element1</Cell>
</Row>
<Row>
   <Cell Type="Main" Id="123">Test</Cell>
   <Cell/>
</Row>
<Row>
   <Cell Type="SubElement">Test Sub Element1</Cell>
   <Cell Type="Element">xyz</Cell>
</Row>
<Row>
   <Cell Type="SubElement">Test Sub Element2</Cell>
   <Cell Type="Element">abc</Cell>
</Row>
<Row>
   <Cell Type="Main" Id="456">Test1</Cell>
   <Cell/>
</Row>
<Row>
   <Cell Type="SubElement">Test1 Sub Element1</Cell>
   <Cell Type="Element">awe</Cell>
</Row>
<Row>
   <Cell Type="SubElement">Test1 Sub Element2</Cell>
   <Cell Type="Element">scd</Cell>
</Row>
</Table>

Now, I need to get the 1st Row’s Id (i.e. Cell[Type=’Main’]/@Id) from the 2nd & 3rd Row’s Element Cell (1st row is the parent row for 2nd & 3rd row).
Similarly I need to access 4th Row’s Id (i.e. Cell[Type=’Main’]/@Id) from the 5th & 6th Row
(4th row is the parent row for 5th & 6th row).

I tried using xsl:variables but I couldn’t assign values dynamically.

Please advise. Thanks in advance

  • 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-27T15:34:11+00:00Added an answer on May 27, 2026 at 3:34 pm

    Use the following expression within a template that is processing a SubElement or Element:

    ../preceding-sibling::Row[Cell/@Type='Main'][1]/Cell/@Id
    

    For example:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="text"/>
        <xsl:strip-space elements="*" />
        <xsl:template match="Cell[@Type[.='SubElement' or .='Element']]">
            [<xsl:value-of select="concat(., '; Parent ID: ',
                    ../preceding-sibling::Row[Cell/@Type='Main'][1]/Cell/@Id)"/>]
        </xsl:template>
        <xsl:template match="Cell"/>
    </xsl:stylesheet>
    

    Outputs (spaces removed):

    [Test Sub Element1; Parent ID: 123]
    [xyz; Parent ID: 123]
    [Test Sub Element2; Parent ID: 123]
    [abc; Parent ID: 123]
    [Test1 Sub Element1; Parent ID: 456]
    [awe; Parent ID: 456]
    [Test1 Sub Element2; Parent ID: 456]
    [scd; Parent ID: 456]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about Access.If for example I have a table with the
I have a question about how to access the member with the same name
I have question concerning a function I created. I would like to show the
This question is mostly just out of academic interest. I started using YUI 3
The problem is like this: I have an array of 500 pointers which point
I have a class, say, CDownloader, that reads some XML data and provides access
In C# I have an intrusive tree structure that looks like this: public abstract
We're using JAXB to unmarshall a fragment of XML which looks a bit like
I have next code that represents graph edges and nodes (simplified for question): public
We have tree structure like this: <Tree> <child1> <child2> <child2> </child1> </Tree> Here the

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.