You are reading a single comment by @ingo and its replies. Click here to read the full conversation.
  • Hi,
    I have tried the function "access the internet", but have encountered problems.
    I have tried several web pages, with each one I get a (different) SaxParseException.

    For example, the following call results in the exception:

    Bluetooth.println(JSON.stringify({t:"htt­p",url:"https://banglejs.com/reference",­xpath:"/html/body/div/h2"}));
    

    Does the call work for anyone? Is it possibly a problem with my phone?

    Using the relevant lines from the BanglejsGadgetBridge project, I was able to recreate the error in a small sample project of my own.

    InputSource inputXML = new InputSource(new StringReader(response));
    XPath xPath = XPathFactory.newInstance().newXPath();
    response = xPath.evaluate(xmlPath, inputXML);
    

    Simple HTML/XML structures work, but complex web pages do not. I think the parser can't handle the embedded JavaScript. But I am not sure.

    I searched for other solutions and tried Jsoup. For me it worked very well.

    Document doc = Jsoup.parse(response);
    response = doc.select(xmlPath).html();
    

    A big disadvantage is that XPath cannot be used, but selector.

    The question is, am I alone with this problem? Can someone help me to get the default implementation to work? Is an implementation with Jsoup possible, or is there something against it?

About

Avatar for ingo @ingo started