Marcel Felipe
Marcel Felipe

Reputation: 45

Importxml google spreadsheet function

I'm trying to import nodes from a xml hosted in my server but I'm getting error: =importxml("http://www.jaguatiricadigital.com/notas_xml/NFe33150117082461000153550020000001001857920160.xml";"//*[@id="webkit-xml-viewer-source-xml"]/nfeProc/NFe/infNFe/ide/natOp")

Though, when I use only a slash as the XPATH query, it returns que whole xml without nodes markups: =importxml("http://www.jaguatiricadigital.com/notas_xml/NFe33150117082461000153550020000001001857920160.xml";"/")

I need to import the nodes as headers and content as rows. The XPATH was copied from Chrome. I have already changed double to single quotes as suggested in another topic. I know that Excel does this very quickly but I use Mac and the office version doesn't support xml import.

What is possibly wrong ? Thanks in advance.

Upvotes: 3

Views: 855

Answers (1)

har07
har07

Reputation: 89325

Your XML has default namespace that you need to consider when creating the XPath. I'm not sure if Google Spreadsheet provide a way to define namespace prefix for use in IMPORTXML XPath. If you can't find one, then you can ignore namespaces completely by using local-name(). For example, the following XPath will return all elements named natOp, ignoring the element's namespace, anywhere in the XML document :

//*[local-name()='natOp']

Quick test :

enter image description here

Upvotes: 4

Related Questions