XMLimport of aria-label value

456 Views Asked by At

I'm blocking on some XMLimport I'm doing in a sheet. So far, the data I've been looking at was quite easy to point at simply using chrome's xpath copy and a few tweaks.

But now, a chunk of what I need is behind a mouse-over on the website and I can't locate it.

From this website wowprogress AF ranking

For example, to get the correct value from that line concerning the character Breakerkill" > "33 I used in Google sheet:

=importxml(A1; "//tr[2]/td[6]/span")

(the A1 cell is where I stored the URL for the sheet)

from that code

<span aria-label="45753 exp" class="hint--bottom-right innerLink" style="font-weight: bold;" xpath="1">33</span>

But now, for my next column, I need that node value aria-label (the "45753 exp" part) and I need assistance.

1

There are 1 best solutions below

1
bcperth On

You are nearly there:

This should locate the value of the aria-label.

=IMPORTXML("https://www.wowprogress.com/artifact_power/fr/","//tr[2]/td[6]/span/@aria-label")

Let me know if that solves the problem.

I tried it and it produces this result:

46568 exp

Also, have a play with this or a similar tool https://www.freeformatter.com/xpath-tester.html. It has lots of examples, including locating elements by attribute or finding the value of attributes. Then you can become a mini-expert on the subject!

Also beware of taking Xpath queries from the browser dev console. It works on the DoM and in loading the URL it may add missing tags like <tbody>. So if you try to use these queries on the URL contents - they won't work - at least without removing the extra selectors.