When trying to parse html as xml in google apps script, this code:
var yahoo= 'http://finance.yahoo.com/q?s=aapl'
var xml = UrlFetchApp.fetch(yahoo).getContentText();
var document = XmlService.parse(xml);
=IMPORTXML("http://finance.yahoo.com/q?s=aapl,"//div[@class='title']")
New XmlService
could not do lenient parse. So no way right now. But you can still use old Xml
service that is support lenient parse (perhaps IMPORTXML
use it as well). The code that works:
var yahoo= 'http://finance.yahoo.com/q?s=aapl'
var xml = UrlFetchApp.fetch(yahoo).getContentText();
var document = Xml.parse(xml, true);
And there is the issue report about no ability to lenient parse in the new XmlService
: https://code.google.com/p/google-apps-script-issues/issues/detail?id=3727
So I propose you to use old way and keep an eye on this issue.