>thanks a lot. It worked..One more question..How to define an attribute as
>type ID to use the method getElementsByID() in the Document
>thanks,
>kusuma
>
If you are not busy adding new nodes to the document, then it works if 
you define the attribute in the DTD as ID. But, if you are busy adding 
new nodes and want to find the new nodes by their IDs, then you must do 
the following:

   Element newNode = doc.createElement("name");
   DocumentImpl docImpl = (DocumentImpl)doc;
   newNode.setAttribute( "id", "new-node-id" );
   newNode.setAttribute( "first", "new first name" );
   Node parent = node.getParentNode();
   parent.appendChild( newNode );
   docImpl.putIdentifier( "new-node-id", newNode );  //   <<----- This 
is what defines the new attribute as an ID
   Element foundNode = doc.getElementById( "new-node-id" );

This is because the ID map is not updated when attributes are set. 
Ideally, Xerces should automatically check whether an attribute is of 
type ID and then call putIdentifier.

Evert


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to