0
votes

I have the following html:

<td>

  <h1>Headline</h1><br>
  <strong>Subheadline</strong><br>

  Text1<br>
  Text2

  <h2>Subheadline2</h2>
  <div>stuff</div>
  <div>more stuff!</div>

</td>

I'm trying to grab "Text1" and "Text2".
After experimenting with Xpath (DOMXPath using php), I've
discovered that "td/text()[2]" matches Text1
and "td/text()[3]" matches Text2
I want to somehow concat them using Xpath, is it possible?

I can't seem to find proper documentation for this anywhere.
W3schools has some examples but this is really not enough.

2

2 Answers

1
votes

The concat() function does what you're trying to do, I believe. Something like concat(/td/text()[2], /td/text()[3]) should work.

I cleaned up your HTML (made all the <br> tags <br/>) and was able to do it with the concat function in OxygenXML.

-1
votes

Seems to be possible, haven't tested though.
From W3 docs - http://www.w3schools.com/xpath/xpath_functions.asp

fn:concat(string,string,...) 

Returns the concatenation of the strings

Example: concat('XPath ','is ','FUN!')
Result: 'XPath is FUN!'