Help - how to create element with proper namespace 2003-03-05 - By Sander Bos
Dear Peter,
> I am simply trying to create a Element that will look like the > following: > > <requestSummary xmlns="urn:expertmgmt"> > > I run into problems when using createElementNS or createAttributeNS. > Here is an exmaple of one of my attempts: > > Element root = doc.createElement("requestSummary"); > Attr att = doc.createAttributeNS("urn:expertmgmt", "xxx"); > root.setAttributeNode(att); > RETURNS: <requestSummary xxx=""/> > > Does anyone know how to create the element I need?
The attribute creation should be: Attr att doc.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns"); att.setValue("urn:expertmgmt"); or you could use root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "urn:expertmgmt");
urn:expertmgmt is the value of the attribute here, http://www.w3.org/2000/xmlns/ is the namespace of the namespace attribute (you would normally not see that URI in any text-representation of the document).
Kind regards,
--Sander.
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|