I’m trying to use the IMPORTXML feature in Google Sheets to extract data from an XML file that I have saved on my Google Drive. The file is named DataRecords.xml, and it includes essential structured data I need.
Here’s the formula I’m using to attempt the import:
Unfortunately, I keep encountering this error message: Imported content is empty.
Additionally, I’ve experimented with various XPath expressions, including /dataroot, but they also result in the same empty content message. When I try using /* as the XPath, I get an error stating “Result too large,” followed by a lot of garbled text.
I’m uncertain whether the issue lies in how I’m linking to the file on Google Drive, my XPath formatting, or possibly issues with the XML file structure itself. Has anyone experienced a similar situation? What’s the correct method for referencing XML files hosted on Google Drive in conjunction with IMPORTXML?
Google Drive sharing links don’t work with IMPORTXML because they redirect to a preview page instead of serving the raw XML. You need the direct download link instead. Change your URL to https://drive.google.com/uc?export=download&id=your_file_id - this skips the preview and lets IMPORTXML grab the actual XML data. Also set your file permissions to “Anyone with the link can view” or IMPORTXML can’t access it. I ran into this exact issue last month and switching to the direct download URL fixed it right away. Your XPath expressions should work fine once you sort out the URL.
yeah, the drive link’s def the issue. you can’t use regular sharing urls with importxml - it just loads google’s preview interface. make the file public first, then switch to the direct download format. replace ‘/open?id=’ with ‘/uc?export=download&id=’ in your url. had the same headache a few weeks ago and this fixed it.
The issue is Google Drive’s file serving - when you use the standard sharing URL, Google wraps it in HTML instead of serving the raw XML that IMPORTXML needs. I ran into this same problem with CSV imports last year. Besides switching to the direct download URL format others mentioned, double-check your XML structure. Open the file in a browser with the corrected URL to make sure it’s returning clean XML without HTML headers. Google sometimes adds metadata that breaks parsing. If you’re still having trouble, try hosting the XML on Google Sites or another web server - it’s way more reliable for IMPORTXML functions.