Note that there are some explanatory texts on larger screens.

plurals
  1. POTagsoup fails to parse html document from a StringReader ( java )
    primarykey
    data
    text
    <p>I have this function:</p> <pre><code>private Node getDOM(String str) throws SearchEngineException { DOMResult result = new DOMResult(); try { XMLReader reader = new Parser(); reader.setFeature(Parser.namespacesFeature, false); reader.setFeature(Parser.namespacePrefixesFeature, false); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new SAXSource(reader,new InputSource(new StringReader(str))), result); } catch (Exception ex) { throw new SearchEngineException("NukatSearchEngine.getDom: " + ex.getMessage()); } return result.getNode(); } </code></pre> <p>It takes a String that contains the html document sent by the http server after a POST request, but fails to parse it properly - I only get like four nodes from the entire document. The string itself looks fine - if I print it out and copypasta it into a text document I see the page I expected.</p> <p>When I use an overloaded version of the above method:</p> <pre><code>private Node getDOM(URL url) throws SearchEngineException { DOMResult result = new DOMResult(); try { XMLReader reader = new Parser(); reader.setFeature(Parser.namespacesFeature, false); reader.setFeature(Parser.namespacePrefixesFeature, false); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new SAXSource(reader, new InputSource(url.openStream())), result); } catch (Exception ex) { throw new SearchEngineException("NukatSearchEngine.getDom: " + ex.getMessage()); } return result.getNode(); } </code></pre> <p>then everything works just fine - I get a proper DOM tree, but I need to somehow retrieve the POST answer from server.</p> <p>Storing the string in a file and reading it back does not work - still getting the same results.</p> <p>What could be the problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload