XPath Assistance

Issues related to W3C XQuery.
JamesO
Posts: 1
Joined: Sat Oct 09, 2021 4:01 pm

XPath Assistance

Post by JamesO » Sat Oct 09, 2021 4:21 pm

Hi all,

I'm trying to build a Google Sheet to bring in column data from a webpage, via the "ImportXML" function.

The HTML snip is below.

After reading up a little on XPath, I have tried :

"//*[@id="results"]/td[1]"

To grab all the data from the first column - but am getting an error.

This:"//td[1]"

Returns patchy data results, as I believe it is too general, i.e. there are other tables on the page.

It is just the column data in the table within <DIV> with an id='results', that I'm interested in.

Full URL (if needed): https://rgtdb.com/events/112484

Thanks in advance

Jim

Code: Select all

<div class="tab-pane active" id="results" role="tabpanel">
 
<table
    data-classes="table table-striped table-hover"
    data-toggle="table"
    data-search="true"
    data-pagination="true"
    data-page-size="50">
    <thead>
    <tr>
        <th class="text-center" scope="col">#</th>
            <th scope="col"></th>
        <th scope="col">Name</th>
        <th scope="col">Finish Time</th>
        <th scope="col">Avg wKg</th>
            <th class="text-center" scope="col">Rank Change</th>
    </tr>
    </thead>
    <tbody>
        <tr>
            <td class="text-center">
1            </td>
                <td>
                    &#x1F947;
                </td>
            <td>    <span class="align-middle">
            <i style="font-size: 15px; color: #B1B1B1" class="fas fa-dot-circle" data-toggle="tooltip" title="SILVER"></i>
            <a class="text-primary" href="/user/49030">Mads Bang</a>
    </span>
 </td>
            <td>
1:54:40.4                    <em class="small"></em>
            </td>
            <td>
4.09            </td>
                <td class="text-center">
                    
        <span style="font-size: 1.4em;"><i class="fas fa-arrow-up"></i></span>
    
                </td>
        </tr>
Attachments
image.png
image.png (18.1 KiB) Viewed 546 times

Radu
Posts: 7697
Joined: Fri Jul 09, 2004 5:18 pm

Re: XPath Assistance

Post by Radu » Mon Oct 11, 2021 7:59 am

Hi,

Are you using Oxygen XML Editor to run the xpath? What error do you get when running the first xpath?
Maybe this xpath would be better for what you want: //*[@id="results"]//td[1]

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply