How do I return multiple columns of data using ImportXML in Google Spreadsheets?

ImportXML supports using the xpath | separator to include as many queries as you like.

=ImportXML("http://url"; "//@author | //@catalogid| //@publisherid")

However it does not expand the results into multiple columns. You get a single column of repeating triplets (or however many attributes you've selected) as shown below in column A.

The following is deprecated

2015.06.16: continue is not available in "the new Google Sheets" (see: The Google Documentation for continue).

However you don't need to use the automatically inserted CONTINUE() function to place your results.

=CONTINUE($A$2, (ROW()-ROW($A$2)+1)*$A$1-B$1, 1)

Placed in B2 that should cleanly fill down and right to give you sane column data.

example screenshot

  • ImportXML is in A2.
  • A3 and below are how the CONTINUE() functions are automatically filled in.
  • A1 is the number of attributes.
  • B1:D1 are the attribute index for their columns.

Another way to convert the rows of =CONTINUE() into columns is to use transpose():

=transpose(importxml("http://url","//a | //b | //c"))

Just concatenate your queries with "|"

=ImportXML("http://twitter.com/status/user_timeline/matthewsim.xml?count=200","/statuses/status/created_at | /statuses/status/text")