Gonnosuke Posted April 14, 2014 Share Posted April 14, 2014 (edited) Hi, Long time lurker, first time poster. I'm having trouble figuring out a way to extract info from a dynamic page that lists order information. The source for the page is making it difficult for me to find the correct Xpath. Here's a condensed snippet of the source to help illustrate: <tr class="cart_item odd cancelled_line_item"> <td class="status_col"> <div class="first_row status"> Processing </div> <div class="second_row isbn"> 9780133050691 <---- This is what I'm after <br> 5606637 </div> </td> ....<tr class="cart_item even cancelled_line_item"> <td class="status_col"> <div class="first_row status"> Cancelled </div> <div class="second_row isbn"> 9780133050691 <---- This is what I'm after <br> 5606638 </div> </td> ... </tr><tr class="cart_item odd cancelled_line_item"> <td class="status_col"> <div class="first_row status"> Processing </div> <div class="second_row isbn"> 9781111221294 <---- This is what I'm after <br> 5606639 </div> </td> Each of the highlighted rows above is a line item on an order and every line item will fall under either cart_item odd cancelled_line_item or cart_item even cancelled_line_item but because of various other elements the tr[x] value is completely dynamic. Large orders can have as many as a dozen of each one of those classes. If the name of the tr class wasn't used more than once I could easily get the Xpath with something like: _FFXpath("html/body/div[3]/div[3]/div[3]/div[1]/table/tbody/tr[@class='cart_item odd cancelled_line_item']//td[1]/div[2]", "textContent" ,9) But since there are multiple matches under that class on any order with 3 or more line items I can't seem to get the path for anything other than the first value found. If I change the parameters for _FFXpath from "textContent", 9 to "", 10 I can get a count so I know it's detecting multiple ISBN's, but I can't seem to find a way to return all of the xpath values for all line items. I'm sure I'm missing something obvious here. Any help would be greatly appreciated. Thank you! [Edited for clarity) Edited April 14, 2014 by Gonnosuke Link to comment Share on other sites More sharing options...
Solution jdelaney Posted April 14, 2014 Solution Share Posted April 14, 2014 This should grab your collection, which you would then need to loop through to get the text. "//tr[contains(@class,'cancelled_line_item')]//div[@class='second_row isbn']" IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Gonnosuke Posted April 14, 2014 Author Share Posted April 14, 2014 (edited) This should grab your collection, which you would then need to loop through to get the text. "//tr[contains(@class,'cancelled_line_item')]//div[@class='second_row isbn']" Thank you so much for the accurate and blazing fast response! Worked great. In case it might be useful to someone in the future, I just wanted to mention that _FFXpath(".//tr[contains(@class,'cancelled_line_item')]//div[@class='second_row isbn']", "textContent",7) outputs the results to an array for easy access. Edited April 14, 2014 by Gonnosuke Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now