Search code examples
google-sheetsarray-formulasgoogle-sheets-querygoogle-sheets-formula

ImportXML Error: Imported XML content can not be parsed


The formula does not work properly on certain pages I guess.

I could load products name and prices, only different with URLs and class names, from the below method.

=IMPORTXML("https://mall.han-don.com/goods/goods_list.php?cateCd=001002","//*[@class='prdName']//text()")

However, it's not loaded with 'Imported XML content can not be parsed.' message.


Solution

  • use this:

    =ARRAYFORMULA(REGEXEXTRACT(QUERY(SUBSTITUTE(ARRAY_CONSTRAIN(IMPORTDATA(
     "https://mall.han-don.com/goods/goods_list.php?cateCd=001002"), 10000, 1), """", ), 
     "where Col1 contains 'strong class=prdName>'"), ">(.+)</strong"))
    

    0


    =ARRAYFORMULA(QUERY({{"";"";SUBSTITUTE(ARRAY_CONSTRAIN(IMPORTDATA(
     "https://mall.han-don.com/goods/goods_list.php?cateCd=001002"), 10000, 1), """", )}, 
     {ARRAY_CONSTRAIN(IMPORTDATA(
     "https://mall.han-don.com/goods/goods_list.php?cateCd=001002"), 10000, 1);"";""}}, 
     "select Col2 where Col1 contains 'span class=cost prdPrice'")&".000원")
    

    0