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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:06:15+00:00 2026-05-20T10:06:15+00:00

<TD colSpan=4> Ref. : XYZ</TD> I am trying to retrieve the value XYZ using

  • 0
  <TD colSpan=4> Ref. : XYZ</TD>

I am trying to retrieve the value XYZ using XPATH

  //td[text()=" Ref. :"]

But i am unable to get that … can anyone find the error ..

  • 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-20T10:06:16+00:00Added an answer on May 20, 2026 at 10:06 am

    Try

    substring-after(//TD[starts-with(text(),' Ref. :')]/text(),' Ref. : ')
    

    That yields

    XYZ
    

    Update

    Following Alejandro’s remark about listing several nodes, here is a Java example of listing several TDs in Java (standard JDK Java parser).

    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.xpath.XPathConstants;
    import javax.xml.xpath.XPathExpression;
    import javax.xml.xpath.XPathFactory;
    
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    
    public class TestXPath {
    
        private static final String FILE = "a.xhtml" ;
        private static final String XPATH = "//td[starts-with(.,'Ref. :')]";
        public static void main(String[] args) {
    
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            docFactory.setNamespaceAware(true);
            DocumentBuilder builder;
            try {
                builder = docFactory.newDocumentBuilder();
                Document doc = builder.parse(FILE);
                XPathExpression expr = XPathFactory.newInstance().newXPath().compile(XPATH);
                Object hits = expr.evaluate(doc, XPathConstants.NODESET ) ;
                if ( hits instanceof NodeList ) {
                    NodeList list = (NodeList) hits ;
                    for (int i = 0; i < list.getLength(); i++ ) {
                        System.out.println( list.item(i).getTextContent().substring( " Ref. :".length() ) );
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

    Applied to the following test xhtml file

    <html>
    <head>
    </head>
    <body>
        <table>
            <thead>
                <tr>
                    <td>col1</td>
                    <td>col2</td>
                    <td>col3</td>
                    <td>col4</td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td colSpan="4">Ref. : Line 1</td>
                </tr>
                <tr>
                    <td colSpan="4">Ref. : Line 2</td>
                </tr>
                <tr>
                    <td colSpan="4">Ref. : Line 3</td>
                </tr>
                <tr>
                    <td colSpan="4">Ref. : Line 4</td>
                </tr>
            </tbody>
        </table>
    </body>
    </html>
    

    It yields

     Line 1
     Line 2
     Line 3
     Line 4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain rowspan and colspan , col and colgroup ? And are these
I am trying to match all <tr> elements that contain the word Source, but
Is there a way I can change colspan of td using CSS or this
I can't get colspan to work when I use a fixed width (IE 7)?
i am tryng to get all the td from each row in which colspan
I've looked through some posts around here, but am still struggling to get my
That is how is the maximum colspan, for example: <table> <tr> <td> 1 </td>
I was wondering if I use colspan attribute in a HTML table that I
Im back!....well the powers that be want to change my nice comment box....does colspan
I am using OpenOffice uno api to iterate through all text in writer document.

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.