Hi Thomas

Thanks for spotting this one - there was a schoolboy error in the
implementation of elementByID() - the recursive loop wasn't behaving
correctly. Its fixed now in CVS and is available in the daily build. It
should be incorporated in the 0.6 release shortly.

I've added a JUnit test case for this (using the document you supplied as
the test case) in src/test/org/dom4j/TestElementByID.java so this should
stay working now for good.

James

----- Original Message -----
From: "Thomas Nichols" <[EMAIL PROTECTED]>
To: "dom4j-user" <[EMAIL PROTECTED]>
Sent: Monday, July 02, 2001 11:25 PM
Subject: [dom4j-dev] elementByID() confusion


> Hello,
> I can't get elementByID to behave as I had expected - what am I doing
wrong?
> The XPath version - selectSingleNode() - works fine, but the elementByID()
> version fails (messageEl == null)
> What am I doing wrong here?
>
> The code <AbstractBranch.java> looks straightforward enough, I can't see
> why it wouldn't work. Any suggestions?
>
> ==== Java snippet ====
>
>              Element messageEl = document.elementByID ("message");
>              //      Element messageEl = (Element)
> document.selectSingleNode ("//html/body/span");
>              if (messageEl == null)
>                  out.println ("\nMessage Not Found!\n");
>              else {
>                  messageEl.clearContent();
>                  messageEl.addText ("Dynamic Sites Indeed");
>              }
>
> ==========
>
> The Document is built with SAXReader.read() on squeak.html:
>
> ==== squeak.html ====
>
>   <html>
>      <head>
>        <title>Squeak!</title>
>      </head>
>      <body>
>        <h1>Squeak!</h1>
>        <span ID="message">squeak squeak squeak</span>
>      </body>
>    </html
>
> ==========
>
> With selectNodes, I see the "Dynamic Sites indeed" message.
>
> Thanks,
> Thomas.
>
>
> _______________________________________________
> dom4j-dev mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/dom4j-dev
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to