Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 506
Marcel Felipe Avatar asked Aug 01 '26 02:08

Marcel Felipe


1 Answers

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

like image 196
har07 Avatar answered Aug 10 '26 02:08

har07



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!