Reputation: 1
text is like
<tag>Head Office41-43 Ricketts Road<tag/> <tag>Mount Waverley, Melbourne<tag/>
iam getting result as
Head Office41-43 Ricketts RoadMount Waverley, Melbourne
but i want it as
Head Office41-43 Ricketts Road Mount Waverley, Melbourne
code i am using is
response.xpath('string(normalize-space(//*/text()[contains(normalize-space(), "{}")]/../..))'.format(marker))
where marker is the text.
so instead of RoadMount
I want Road Mount
see the tag wrapped: enter image description here
this is the code iam using enter image description here
Upvotes: 0
Views: 198
Reputation: 21446
Your xpath is returning multiple values - all you have to do is join them with a separator:
xpath = 'string(normalize-space(//*/text()[contains(normalize-space(), "{}")]/../..))'.format(marker))
results = " ".join(response.xpath(xpath).getall())
# ^^^^^^^^
# note: don't forget to use getall to retrieve all results
print(results)
Upvotes: 1