Java: how to parse an html string for XML tool consume? -


which library allow me evaluate xpath on html string ?

i have tried using javax package seems fail:

string docroot = "<div><i>items <b>sold</b></i></div>"; xpath xxpath = xpathfactory.newinstance().newxpath(); inputsource docroot = new inputsource(new stringreader(subelements));  string result = (string) xxpath.evaluate("//b", docroot, xpathconstants.string); 

try following instead, there errors in code sample:

import java.io.stringreader; import javax.xml.xpath.xpath; import javax.xml.xpath.xpathconstants; import javax.xml.xpath.xpathfactory; import org.xml.sax.inputsource;  public class demo {      public static void main(string[] args) throws exception {         string docroot = "<div><i>items <b>sold</b></i></div>";         xpath xxpath = xpathfactory.newinstance().newxpath();         inputsource inputsource = new inputsource(new stringreader(docroot));          string result = (string) xxpath.evaluate("//b", inputsource, xpathconstants.string);         system.out.println(result);     }  } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -