0
votes

I'm trying to find the xpath query for use in google spreadsheets (importXML function) to obtain the following information contained in the HTML code below: "ThisIsCompanyName" & "123456".

<tr valign="top" class="small"> 
                                <th width="18%" bgcolor="#EFEFEF" id="name" class="commonFontSize"> 
                                  <div align="right">Company Name</div></th>
                                <td width="33%" bgcolor="#FFFFFF" headers="name" align="left" style="padding-left:3px;"> 
                                    <span id="ctl00_ContentPlaceHolder1_lblTblCarrierName" class="oneSmallFontSize">ThisIsCompanyName</span>    
                                </td>
                                <th width="20%" bgcolor="#EFEFEF" id="dot" class="commonFontSize"> 
                                  <div align="right">U.S. DOT Number</div></th>
                                <td width="29%" bgcolor="#FFFFFF" headers="dot" align="left" style="padding-left:3px;"> 
                                    <span id="ctl00_ContentPlaceHolder1_lblTblDOTNumber" class="oneSmallFontSize">123456</span>  
                                </td>
                              </tr>

Using Chrome, if I use the "inspect element" function and then "copy xpath" I get the following....

    //*[@id="ctl00_ContentPlaceHolder1_lblTblCarrierName"]
    //*[@id="ctl00_ContentPlaceHolder1_lblTblDOTNumber"]

But these are not yielding the results i need. I have zero knowledge of programming and am just trying to learn some rudimentary web scraping techniques.

1
If it helps here's the website I'm trying to get this information from... ai.fmcsa.dot.gov/PassengerSearch/… - Patrick

1 Answers

1
votes

Try this

//span[@id='ctl00_ContentPlaceHolder1_lblTblCarrierName']/text()
//span[@id='ctl00_ContentPlaceHolder1_lblTblDOTNumber']/text()

And if you use this xpath, it will return "ThisIsCompanyName123456"

//span[@class='oneSmallFontSize']/text()