HtmlUnit / htmlunit-neko

HtmlUnit adaptation of NekoHtml
Apache License 2.0
17 stars 15 forks source link

CloneNode is not working on org.w3c.dom.Node #119

Closed LogeswaranRamasamy closed 5 months ago

LogeswaranRamasamy commented 5 months ago

@rbri I am using htmlUnit-Neko parser to read an Html Document. I was able to successfully fetch the nodes but when I am trying to clone a org.w3c.dom.Node getting unimplemented Exception

java.lang.UnsupportedOperationException: unimplemented at org.htmlunit.cyberneko.util.SimpleArrayList.iterator(SimpleArrayList.java:234) at org.htmlunit.cyberneko.xerces.dom.AttributeMap.cloneContent(AttributeMap.java:388) at org.htmlunit.cyberneko.xerces.dom.AttributeMap.cloneMap(AttributeMap.java:367) at org.htmlunit.cyberneko.xerces.dom.ElementImpl.cloneNode(ElementImpl.java:146)

How to resolve this issue ?

rschwietzke commented 5 months ago

That is based on the performance tuning I applied. The simpler array list is not handling iterators at the moment.  @rbri How about adding a test case and I will fix it over the weekend?

LogeswaranRamasamy commented 5 months ago

@rschwietzke thanks for the swift reply. Is there any other option/workaround to achieve CloneNode functionality at the moment ? Else any workaround available for this issue for the time being ?

rschwietzke commented 5 months ago

Well, you might be able to implement that yourself and just put that class in front of the classpath. You can optionally just fork HtmlUnit and replace SimpleArrayList in AttributeMap by an ArrayList, build it and add to your classpath.

LogeswaranRamasamy commented 5 months ago

Thanks @rschwietzke. Hope this will be fixed & the latest version be pushed to the Maven repo soon ✌️

rschwietzke commented 5 months ago

If you could share your base code you use to create the failures, please? Might be a good base for a test case.

rbri commented 5 months ago

@rschwietzke will write some tests

rbri commented 5 months ago

@rschwietzke nothing to do for you - enjoy your weekend @LogeswaranRamasamy thanks for giving this version a try - should be fixed now. please try with the latest snapshot build (4.2.0-SNAPSHOT)

rbri commented 5 months ago

@LogeswaranRamasamy can i close ris?

rbri commented 5 months ago

released