Google-sheets – Using ImportXML to pull HTML tags along with data

google sheetsimportxml

Can ImportXML be used to pull the HTML tags along with the data?

For example:

importxml(A1,"//div[@id='qlist-wrapper']") on stackoverflow.com 

will pull all the data in the div with the id qlist-wrapper in an imploded format.

Is there a way where I can pull the data along with the relevant <div>s and <li>s and <ul>s ?

Strange request, I understand, but I have a need in one place and anyway of pulling the tags along with the data together will be really helpful.

Best Answer

SO it turns out you can do this after all!

=importxml("http://stackoverflow.com","//div[@id='qlist-wrapper']//@*")

enter image description here

Related Topic