php - XPath getting text from all elements that match XPath query -


i having lot of difficulty constructing query return text elements below in 1 string (assume other elements on page contain text , not span or div elements).

note: because using php xpath engine, forced use solution xpath 1.0.

html

<div>hello</div> <div>world</div> <div>!!!</div> <span>this</span> <span>is</span> <span>cool</span> 

xpath

normalize-space(//*/div | //*/span) 

desired output:

hello world!!! cool

i appreciate suggestions. many in advance!

the normalize-space() xpath 1.0 function work on string - not on node-set. in example code have node-set it's first parameter:

 normalize-space(//*/div | //*/span) 

in such case, "string-value of node-set" string value of first node. not fitting needs.

to best of knowledge not possible achieve you're looking single xpath 1.0 query alone. it's possible of php creating string you're looking registering php function you're looking for.

see well:


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -