I have been extensively using lxml for developing algos. But now, due to performance issues, I have to migrate to Java. Moral is, can I find as awesome as lxml dom parser in Java?
> Key requirements :
1) feature like text_content() 2) iterchildren and 3) iterparent() and itersiblings()--- (if xpath is there, I think we can do such traversing, not sure).
Jsoup is famous there, but not sure if all can be done. I just want to port algorithms not heavy rewriting. Please suggest.
Thanks.
Why Java : I am doing complex nlp and dom parsing tasks. Python is first choice and will remain.Writing c-extension is one thing, and performing complex nlp tasks is another, and merging two is yet another thing. Hence Java. Nothing offensive.
Saxon is your best bet in my opinion http://saxon.sourceforge.net . A bunch of examples can be found in this download of saxon-resources9-4.zip found here: http://sourceforge.net/projects/saxon/files/Saxon-HE/9.4/ like xpath expressions:
XPathExpression findLine =
xpe.compile("//LINE[contains(., $word)]");
XPathExpression findLocation =
xpe.compile("concat(ancestor::ACT/TITLE, ' ', ancestor::SCENE/TITLE)");
XPathExpression findSpeaker =
xpe.compile("string(ancestor::SPEECH/SPEAKER[1])");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With