Help - how to create element with proper namespace 2003-03-05 - By Sander Bos
Dear Peter,
> Hey, thanks for the super quick response. I will give that a try. My > question dealt with creating an element like: > <requestSummary xmlns="urn:expertmgmt"> > > I may need to use something like: > <xxx:requestSummary xmlns="urn:expertmgmt"> > > How would I be able to add the prefix 'xxx' to my elements?
You used createElement in your example, but that is actually not a good idea in a namespace aware environment (that's hidden somewhere in the DOM specification), so you should use Element root = doc.createElementNS(XXX, "xxx:requestSummary"); where XXX is a String-variable that represents a URL for the prefix 'xxx'. Since you specify a prefix that may not be null. By the way, if you want requestSummary to be in the urn:expertmgmt namespace, then using the xxx prefix is not actually useful here as you defined it as the default namespace, then you would use: Element root = doc.createElementNS("urn:expertmgmt", "requestSummary"); (if you want to use the xxx-prefix, you should use xxx:requestSummary as element-name and xmlns:xxx as attribute-name)
Kind regards,
--Sander.
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|