<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2523" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2>I'm using the XPath
functionality to set an XPATH String and then call the
selectNodes(sourceDocument) to get a list of Content back based on the XPATH.
When I iterate over the List of objects in the List (all should be Element
objects), I can see that everything is as expected. However, when I take one of
the Element objects in the List and convert it to a Document, I get the entire
Docuement back, versus just the Element I am using and all of its children. The
code looks like this:</FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2>XPath myXpath =
XPath.newInstance("xpath to several elements downstream of the
root");</FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2>Element
currentElement = null;</FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2>Iterator itr =
myXpath..selectNodes(doc).iterator(); //doc is my XML
Document</FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2>while
(itr.hasNext()) {</FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005> <FONT face=Arial
size=2>currentElement = (Element) itr.next();</FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2><SPAN
class=711013916-27102005><FONT face=Arial size=2> //Iterating
over the currentElement's children gives me what I expect, all child elements
names are output</FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2><SPAN
class=711013916-27102005><FONT face=Arial size=2> Iterator itr
= currentDiagnosis.getChildren().iterator();<BR> while
(itr.hasNext()) {<BR>
System.out.println(((Element) itr.next()).getName());<BR>
}<BR></FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2><SPAN
class=711013916-27102005><FONT face=Arial size=2> //But
putting the currentElement to a Document gives me my original Document back.
Wierd to me but perhaps this is by design.</FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2><SPAN
class=711013916-27102005><FONT face=Arial size=2> Format
format = Format.getPrettyFormat();<BR> XMLOutputter
output = new
XMLOutputter(format);<BR> System.out.println(output.outputString(currentElement.getDocument()));<BR></FONT></SPAN></FONT></SPAN><SPAN
class=711013916-27102005><FONT face=Arial size=2>}</FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial size=2>Assuming this
behavior is by design, how can I get a Document object of my Elements in order
to write XPath expressions on these separatly?</FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2>Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2>Kevin</DIV></FONT></SPAN>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=711013916-27102005><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<P style="MARGIN-BOTTOM: 0in"></P>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>