[Advanced-java] Issues with selectSingleNode and cloneNode

davide.falzoni at libero.it davide.falzoni at libero.it
Wed Nov 12 12:54:15 PST 2008


Hi Folks, 
I'm spiking xpath and  I've a test:


public void testParse() throws 
Exception
	{
		DocumentBuilderFactory factory = DocumentBuilderFactory.
newInstance();
		Document doc = factory.newDocumentBuilder().parse(new 
InputSource(new StringReader("<fragment><beta></beta></fragment>")));

		
assertNotNull(XPathAPI.selectSingleNode(doc.getDocumentElement().cloneNode
(true), "//fragment"));
	}

the test gives me a red bar.

The following

public 
void testParse() throws Exception
	{
		DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();
		Document doc = factory.
newDocumentBuilder().parse(new InputSource(new StringReader
("<fragment><beta></beta></fragment>")));

		assertNotNull(XPathAPI.
selectSingleNode(doc.getDocumentElement(), "//fragment"));
	}

gives me a green 
bar.
Is there a problem in the cloneNode?
Thanks in advance
Davide




More information about the Advanced-java mailing list