1

I'm trying to navigate through the page via xPath and obtain an array of text fields within certain spans

The div stricture is the following:

.class1(the only one present on the page) -> .some other divs. -> .class2(can be multiple of them) -> span, containing text

Could someone help me with $xpath->query()

Thank you for your time.

John W
  • 151
  • 6
  • Actual HTML sample would be more definite (less ambiguous) way to describe the 'div structure' – har07 Aug 30 '15 at 03:28

1 Answers1

0

Assuming that -> 'operator' you use means that the element on the right side is direct child of the element on the left side, the XPath would be as follow (formatted into multilines for readability) :

//*[contains(concat(' ', normalize-space(@class), ' '), ' class1 ')]
/div
/*[contains(concat(' ', normalize-space(@class), ' '), ' class2 ')]
/span

Part of the above XPath expression which used for matching CSS class discussed in this thread : How can I find an element by CSS class with XPath?

Community
  • 1
  • 1
har07
  • 88,338
  • 12
  • 84
  • 137