dom - JavaFX WebEngine and XPath case sensitivity issue? -


i have document object javafx 2.2 webengine. in code below, though loaded document has html tag in lower case, getdocumentelement().getnodename() returns in upper case. result, xpath query falis locate node (because expects html tag in lower case). in particular case, can force output of getnodename() lower case, in general, if document had mixed case tags, how 1 handle it?

public class xpath3 extends application {  webview view; webengine engine;  @override public void start(stage primarystage) {      view = new webview();     engine = view.getengine();      engine.getloadworker().stateproperty().addlistener(             new changelistener<worker.state>() {         @override         public void changed(observablevalue<? extends worker.state> ov, worker.state t, worker.state t1) {             if (t1 == worker.state.succeeded) {                 document doc = engine.getdocument();                 xpath xpath = xpathfactory.newinstance().newxpath();                 xpath.setnamespacecontext(new namespacecontext() {                     @override                     public string getnamespaceuri(string pfx) {                         if ("ns1".equals(pfx)) {                             return "http://www.w3.org/1999/xhtml";                         }                         return xmlconstants.null_ns_uri;                     }                      @override                     public string getprefix(string string) {                         return null;                     }                      @override                     public iterator getprefixes(string string) {                         return null;                     }                 });                 nodelist nl = null;                 string path = "/ns1:" + doc.getdocumentelement().getnodename();                 //path = "/ns1:html";                 system.out.println(path);                 try {                     nl = (nodelist) xpath.compile(path).evaluate(doc, xpathconstants.nodeset);                 } catch (xpathexpressionexception ex) {                     system.exit(-11);                 }                 system.out.println("xpath: " + path + "    count: " + nl.getlength());                 system.exit(-1);             }         }     });      platform.runlater(new runnable() {         @override         public void run() {             engine.loadcontent("<html><body> hello! </body></html>");         }     }); }  /**  * main() method ignored in correctly deployed javafx application.  * main() serves fallback in case application can not  * launched through deployment artifacts, e.g., in ides limited fx  * support. netbeans ignores main().  *  * @param args command line arguments  */ public static void main(string[] args) {     launch(args); } 

}


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -