0

This should be simple but isn't.

I am using:

//*[@class="mainbody right"]//div[2]/div[2]/div[1]/div[1]/a

to generate a list of elements:

< a href="https://someurl1.com" class="title getFull" data-view="full"> Some plain text 1 < /a>

< a href="https://someurl2.com" class="title getFull" data-view="full"> Some plain text 2 < /a>

< a href="https://someurl3.com" class="title getFull" data-view="full"> Some plain text 3 < /a>

What I want instead is either:

href="https://someurl1.com"

href="https://someurl2.com"

href="https://someurl3.com"

or

https://someurl1.com

https://someurl2.com

https://someurl3.com

How do I get rid of the unwanted class & data-view & plain text? I have tried appending /@href and a great number of other things but to no avail.

Dave Lowe
  • 11
  • 1

1 Answers1

0

If you really want to take values from position elements then you need to change the XPath like:

//*[@class="mainbody right"]//div[2]/div[2]/div[1]/div[1]/a/@href
Amrendra Kumar
  • 1,806
  • 1
  • 7
  • 17
  • As I mentioned in the question title and message body, adding /@href does not work. It does not strip the class= and the data-view= and the plain text from the list of elements. It does not change the output at all (although I think it should). – Dave Lowe Dec 12 '18 at 14:09
  • I dont know which language you are using? I try to solve it by XSLT See below links which will help you: http://xsltransform.net/93wkLHu/2 or http://xsltransform.net/93wkLHu – Amrendra Kumar Dec 12 '18 at 14:23
  • Thank you! When I saw that I realised that there was a PEBCAK at work here. The syntax that you suggested in your answer (which was the same as the one I suggested didn't work) in fact works fine. I had misconfigured the parser I was using to test it.... How embarrassing. – Dave Lowe Dec 12 '18 at 14:34