Closed felipeotarola closed 4 years ago
Hello.
Is it possible to retrieve an attribute value from an element? I have been trying different methods,
My dom element looks something like this.
`
<div class="Grid__cell"><a href="17ae0a.png" id="artimglink_47373113"> <img src="17ae0a.png_0_0_100_100_65_80_0.png" id="artimg_47373113" ></a> </div> <div class="Grid__cell"><a href="4ff9fc.png" id="artimglink_47373115"><img src="4ff9fc.png_0_0_100_100_65_80_0.png" id="artimg_47373115" ></a> </div> <div class="Grid__cell"><a href="3dcf91.png" id="artimglink_47373117"><img src="3dcf91.png_0_0_100_100_65_80_0.png" id="artimg_47373117" ></a> </div> <div class="Grid__cell"><a href="032205.jpg" id="artimglink_47373119"> <img src="032205.jpg_0_0_100_100_59_80_0.jpg" id="artimg_47373119" ></a> </div>
Where I want to get the href value from the link.
I tried something like this let images = elements "//*[contains(@id, 'artimglink')]/@href" |> List.map read but that didn't obviously work.
Any ideas :)?
Try this
let images = elements "[id^=artimglink]" |> List.map (fun el -> el.GetAttribute("href"))
Nice! Thank you. worked as a charm
Hello.
Is it possible to retrieve an attribute value from an element? I have been trying different methods,
My dom element looks something like this.
`
Where I want to get the href value from the link.
I tried something like this let images = elements "//*[contains(@id, 'artimglink')]/@href" |> List.map read but that didn't obviously work.
Any ideas :)?