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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:44:00+00:00 2026-05-23T01:44:00+00:00

I am working on a project that uses XSLT to transform an HTML string

  • 0

I am working on a project that uses XSLT to transform an HTML string to extract some specific values. Can you please look at the HTML/XSLT below and see what it is that I am doing wrong?

BTW In the HTML below I need to extract value from <a> which says “something” (XPATH = //div[@id=’result’]/div[2]/div[1]/a[1]):

<html>
    <head></head>
    <body>
        <div>
            <div id="whatever">
                <!--other stuff-->
            </div>
            <div id="whatever2">
                <!--other stuff-->
                <div>
                    <div class='listtable'>
                        <div>
                            <div id="result">
                                <div class="ignore">
                                    <!--other stuff-->
                                </div>
                                <div>
                                    <div>
                                        <a>something</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div id="result">
                                <div class="ignore">
                                    <!--other stuff-->
                                </div>
                                <div>
                                    <div>
                                        <a>something</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>

so, the XSLT i came up with looks like this but it doesnt work …

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
      <html>
      <body>
      <h2>My Link Collection</h2>
        <table border="1">
          <tr bgcolor="#9acd32">
            <th>Title</th>
          </tr>
          <xsl:for-each select="//div[@id='result']">
          <tr>
            <td><xsl:value-of select="/div[2]/div[1]/a[1]"/></td>
          </tr>
          </xsl:for-each>
        </table>
      </body>
      </html>
    </xsl:template>
    </xsl:stylesheet>

P.S.: I have worked with XPATHS before but I have no experience with XSLT and for whatever reason Visual Studio crashes when I try to debug so I have no clue what went wrong here.

Thanks for your help!

  • 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-23T01:44:01+00:00Added an answer on May 23, 2026 at 1:44 am

    what it is that I am doing wrong?

    It’s just a tiny error you are committing. The XPath should be:

    "div[2]/div[1]/a[1]"
    

    In this way you correctly select the elements starting from the current context of the xsl:for-each. In the way you have provided (with the forwardslash at the beginning of the XPath), you are trying to select the elements starting always from the root of the input document.

    for whatever reason Visual Studio crashes when I try to debug so I have no clue what went wrong here.

    If Visual Studio is crashing is probably because some flaw there is in it. May be you need some patch. The XSLT you have provided is correct and won’t never going to crash with an XSLT processor. You should obtain a successful result also with the following identical transform:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
            <html>
                <body>
                    <h2>My Link Collection</h2>
                    <table border="1">
                        <tr bgcolor="#9acd32">
                            <th>Title</th>
                        </tr>
                        <xsl:apply-templates select="//div[@id='result']"/>
                        </table>
                    </body>
                </html>
            </xsl:template>
    
            <xsl:template match="div[@id='result']">
                <tr>
                    <td><xsl:value-of select="div[2]/div[1]/a[1]"/></td>
                </tr>
            </xsl:template>
    
        </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a project that uses some IronPython scripts to as plug-ins, that utilize
I am working on a project that uses some plugins. These plugins are introduced
I am working on a project that uses the asp.net ajax control toolkit and
I'm working on a project that uses an MDI application with a navigation panel
So I am working on a project that uses a ASP.NET server and we
I'm working on a source-code visualization project that uses the Processing core library. The
I am working on a large project that uses the STL and have a
I am working on a software development project that uses code written primarily in
I´m working on a project that basically will show some data collected from hardware
A plea for help! Can anyone share a simple GWT2.0 project that uses 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.