Now, if instead of //food you pass /* as the xpath_query, all the data in that XML file would be loaded into the Google Sheets.Ĭool, right? Well, the IMPORTXML function is flawed in one major way. The snippet above should load all the food on the menu into Google Sheets as shown in the image below. In the snippet above, the first argument is the URL of our sample XML file, and /food, the second argument, is the xpath_query- it scrapes and loads all the items wrapped around the tag in our XML file. To import XML to Google Sheets in this case, open your Google Sheets, select a cell and paste the snippet below. If you look at the XML file, you’d see that each food is wrapped within the tag. Given this XML file, that’s a breakfast menu with a list of different varieties of food, let’s load all the food into Google Sheets. Importing a food menu from XML to Google Sheets To concretize this, let’s consider an example. For example, if we specify “h2” as the xpath_query, the function will scrape all H2 headings and load them into Google Sheets.Īdditionally, we could also use the wild card (”/*”) xpath_query to scrape and load all the content of an XML file into Google Sheets.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |