-2
<div class="search-page-right-pannel">

<div class="search-page-heading-red" style="font-weight:400; margin-bottom:7px; margin-top:-4px; text-align:left">

Big Bazaar (Future Group) <b>(Future)</b> </div>
    <img src="images/address-icon.png" alt="" />&nbsp; Knowledge House, Shyam Nagar Off Jogeshwari-Vikhroli Link Road                                 Jogeshwari (East)<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mumbai                    Maharashtra , 400060    <div class="detail-line"><img src="images/call.png" alt="" /> (022) 30841300  66442200  61190000<!--<span onmouseover="TagToTip('Span2')" onmouseout="UnTip()"><img src="images/call.png" alt="" /> <u style="color: #3079af">click to view number</u></span>-->
  <img src="images/website-icon.png" alt="" style="margin-left:80px;" /> <a href="http://www.bigbazaar.com" target="_blank" class="pglink">www.bigbazaar.com</a> <span style="float:right"> </span>
 </div>

I Want the XPath of

Knowledge House, Shyam Nagar Off Jogeshwari-Vikhroli Link Road Jogeshwari (East) Mumbai Maharashtra , 400060

and also separate the elements of phone_no and website

(022) 30841300 66442200 61190000 www.bigbazaar.com

1
  • Sounds like you don't want the XPath of an html element at all; you want the XPath of some text nodes (that are children of HTML elements). What XPath expressions have you tried, and what was the result?
    – LarsH
    Aug 28, 2014 at 15:54

1 Answer 1

1

You could try an XPath expression like:

//div[@class='search-page-right-pannel']/text()[3]
  • The word pannel looks like a typo, but I don't know whether it's actually spelled that way on the web page you're working with.
  • This will get you the third text node child of the specified div element. That may be the wrong number, depending on whitespace processing. You could try [1] or [2] instead of [3], but either way it'll be fragile. Less fragile would be to take advantage of the img element:

.

//div[@class='search-page-right-pannel']/img[@src='images/address-icon.png']/
   following-sibling::text()[1]

Similarly, the phone number could be selected using

//div[@class='search-page-right-pannel']/img[@src='images/call.png']/
   following-sibling::text()[1]

and the domain name:

//div[@class='search-page-right-pannel']/a[@class='pglink']/text()

Take a look at how these expressions work. I'd rather help you learn how to fish than just give you a fish. Let me know if you have questions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.