Hi all,

I seem to be stumped on this one.  I haven't been using the dom4j api long and I'm 
having trouble pulling a node set our of one document and then using it to create 
another.  for example I have the following xml:

<aaa>
        <a1>
                <bbb />
                <ccc />
        </a1>
        <a1>
                <bbb />
                <ccc />
        </a1>
</aaa>

I want to pick up the first a1 and create a document as follows:

<onlyone>
        <a1>
                <bbb />
                <ccc />
        </a1>
</onlyone>

What I get is:
<onlyone>
        <bbb />
        <ccc />
</onlyone>
        
Here's the code (removed try...catch for brevity)

    SAXReader reader = new SAXReader();
    Document inDoc = reader.read(f);                    
    List selectedList = inDoc.selectNodes("aaa/a1");
    Iterator suspects = selectedList.iterator();

    for (;suspects.hasNext();)
    {
      Branch treeFragment = (Branch)suspects.next();

      Document document = DocumentHelper.createDocument();
      Element root = DocumentHelper.createElement("suspect");
      document.setRootElement(root);

      root.appendContent(treeFragment);
        System.out.println(document.asXML());
    }

Any ideas?  Am i missing something obvious?  Thanks for any help,
Marty 
  
NOTICE: This E-mail may contain confidential information. If you are not 
the addressee or the intended recipient please do not read this E-mail 
and please immediately delete this e-mail message and any attachments 
from your workstation or network mail system. If you are the addressee 
or the intended recipient and you save or print a copy of this E-mail, 
please place it in an appropriate file, depending on whether 
confidential information is contained in the message. 
 
 
ą^){([~y*x~z+-ZԨ~ਝjvzg,}xvq[܆)qZn)b'jwZqZ~tZ+ky/jXm
)zǜozǿ 
٥vf)+-vX(~zwilqzlX)ߣh

Reply via email to