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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:13:41+00:00 2026-06-17T17:13:41+00:00

I have a rather flat table that looks like <tr> <td class=tableResultsA nowrap>1</td> <td

  • 0

I have a rather flat table that looks like

<tr>
<td class="tableResultsA" nowrap>1</td>
<td class="tableResultsA" nowrap><A HREF="docs/123456" target="_blank">Title</A></td>
<td class="tableResultsA" nowrap>SNIPPET</td>
<td class="tableResultsA" nowrap>Date</td>
<td class="tableResultsA" nowrap>Category</td>
</tr>

<tr>
<td class="tableResultsB" nowrap>1</td>
<td class="tableResultsB" nowrap><A HREF="docs/678901" target="_blank">Title</A></td>
<td class="tableResultsB" nowrap>SNIPPET</td>
<td class="tableResultsB" nowrap>Date</td>
<td class="tableResultsB" nowrap>Category</td>
</tr>

I need to create a document out of this data, consisting of URL, Title and Snippet.

I’ve set my root result node to this:

<scope>
<xsl:value-of select>"//td[@class='tableResultsA'][2] | //td[@class='tableResultsB'][2]"
</scope>

For my document, I have the following:

<xsl:template match="//td">
   <document url="{a/@href}">
     <content name="title">
        <xsl:value-of select="a" />
     </content>
     <content name="snippet">
        <xsl:value-of select="//td[@class='tableResultsA'][3] | //td[@class='tableResultsB'][3]" />
     </content>
    </document>
  </xsl:template>

The problem is the snippet. I’m getting the exact same result in my snippet output so it isn’t traversing the data. I’m not an XPath expert. I’m wondering if following or following-sibling would work but I haven’t been able to find a good example for them anywhere.

Any help would be appreciated.

  • 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-17T17:13:42+00:00Added an answer on June 17, 2026 at 5:13 pm

    This transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="tr">
      <document url="{td/A/@HREF}">
         <content name="title">
            <xsl:value-of select="td/A"/>
         </content>
         <content name="snippet">
            <xsl:value-of select="td[3]"/>
         </content>
      </document>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the corrected (to become well-formed XML document) provided input:

    <table>
        <tr>
            <td class="tableResultsA" nowrap="nowrap">1</td>
            <td class="tableResultsA" nowrap="nowrap">
                <A HREF="docs/123456" target="_blank">Title</A>
            </td>
            <td class="tableResultsA" nowrap="nowrap">SNIPPET</td>
            <td class="tableResultsA" nowrap="nowrap">Date</td>
            <td class="tableResultsA" nowrap="nowrap">Category</td>
        </tr>
        <tr>
            <td class="tableResultsB" nowrap="nowrap">1</td>
            <td class="tableResultsB" nowrap="nowrap">
                <A HREF="docs/678901" target="_blank">Title</A>
            </td>
            <td class="tableResultsB" nowrap="nowrap">SNIPPET</td>
            <td class="tableResultsB" nowrap="nowrap">Date</td>
            <td class="tableResultsB" nowrap="nowrap">Category</td>
        </tr>
    </table>
    

    produces the wanted, correct result:

    <document url="docs/123456">
       <content name="title">Title</content>
       <content name="snippet">SNIPPET</content>
    </document>
    <document url="docs/678901">
       <content name="title">Title</content>
       <content name="snippet">SNIPPET</content>
    </document>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather complex Flat File that I'm trying to parse using SSIS.
I have rather large project that uses ICU regex classes. Basically it might run
I have some rather odd behavior in my D program that I've narrowed down
I have a rather large text corpus, of which I would like to check
I have a rather huge query that is needed in several stored procedures, and
I accidentally deleted some builds for a job that I would have rather kept.
I have a rather generic model, as follows: class Keyword(models.Model): ancestors = models.ManyToManyField(Keyword) name
While importing data from a flat file, I noticed that some of lines have
I have rather simple task and I would like to ask you for recommendation.
I have rather simple HttpClient 4 code that calls HttpGet to get HTML output.

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.