可能是由于结构导致的 importXML 解析错误

importXML parsing error presumably due to structure

我正在尝试从在线 POS 数据库中读取一些数据,并且数据在 XML 中排序,每行数据量相对适中,也没有任何可能导致任何奇怪情况发生的特殊字符.

然而,当我使用 =importXML 函数时,出现 'Imported XML Content Cannot Be Parsed' 错误。使用 =importdata 可以完美地工作,但我真的很想能够使用 xpath 来减轻计算和编程的负担。

浏览器访问 API return 的示例,时间有限:

35720.08.201513:32Iced latteCoffee and Tea125,00Cash00Terminal 1 35820.08.201513:39Cappuccino largeCoffee and Tea120,00Cash00Terminal 1 35820.08.201513:39FOC 20Coffee and Tea1-20,00Cash00Terminal 1 35920.08.201513:50btl waterSoda etc115,00Card00Terminal 1 36020.08.201513:51PostmixSoda etc115,00Card00Terminal 1

而 =importdata returns:

<?xml version="1.0" encoding="ISO-8859-1"?>
<XML>
<sales>
<line id="965848892794"><chk>357</chk><date>20.08.2015</date><time>13:32</time><product id="271220">Iced latte</product><product_group id="13494">Coffee and Tea</product_group><amount>1</amount><price>25 00</price><payment_type>Cash</payment_type><clerk>0</clerk><pax>0</pax><department>Terminal 1</department><ean ean_1="" ean_2="" ean_3="" ean_4="" /></line>
<line id="965848893275"><chk>358</chk><date>20.08.2015</date><time>13:39</time><product id="271218">Cappuccino large</product><product_group id="13494">Coffee and Tea</product_group><amount>1</amount><price>20   00</price><payment_type>Cash</payment_type><clerk>0</clerk><pax>0</pax><department>Terminal 1</department><ean ean_1="" ean_2="" ean_3="" ean_4="" /></line>
<line id="965848893276"><chk>358</chk><date>20.08.2015</date><time>13:39</time><product id="271310">FOC 20</product><product_group id="13494">Coffee and Tea</product_group><amount>1</amount><price>-20    00</price><payment_type>Cash</payment_type><clerk>0</clerk><pax>0</pax><department>Terminal 1</department><ean ean_1="" ean_2="" ean_3="" ean_4="" /></line>
<line id="965848893960"><chk>359</chk><date>20.08.2015</date><time>13:50</time><product id="271206">btl water</product><product_group id="13493">Soda etc</product_group><amount>1</amount><price>15    00</price><payment_type>Card</payment_type><clerk>0</clerk><pax>0</pax><department>Terminal 1</department><ean ean_1="" ean_2="" ean_3="" ean_4="" /></line>
<line id="965848894015"><chk>360</chk><date>20.08.2015</date><time>13:51</time><product id="271199">Postmix</product><product_group id="13493">Soda etc</product_group><amount>1</amount><price>15  00</price><payment_type>Card</payment_type><clerk>0</clerk><pax>0</pax><department>Terminal 1</department><ean ean_1="" ean_2="" ean_3="" ean_4="" /></line>
</sales></XML>  

我已经尝试了页面上所有建议的回复,但似乎每个人都比 'problem-process' 做得更进一步。我问 POS 公司他们是否对 XML 结构有任何问题,答案是否定的。请注意,我对编程的正规教育为零,所以答案可能很简单。

注意:如果没有我的机密登录凭据,API 就不能 return 任何东西,这显然必须不让 public 看到。但如果现有的不合适,我可以为您提供您想要的任何数据。

IMPORTXML 仅能够访问可用内容而无需身份验证,其他内容可供知道 URL 的人使用,无需他们先登录。另一种方法是使用 Url 从 Google Apps 脚本获取服务。

相关问答

  • Login using UrlFetchApp function and scrape private data
  • Import private data into Google Spreadsheet