You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Scot Nielsen <Sc...@microfocus.com> on 2002/04/10 18:13:30 UTC

Knowing which namespace prefix to use

Hi, during my trials and tribulations of learning about and using DOM I have
often found myself asking "there must be an easier way to do this?" and more
often than not, there has been. However, in this case I can't seem to find
it...
 
I will eventually need to serialise the DOM I process and as the schema and
xml documents I'm using make considerable use of namespaces, its necessary
that I correctly prefix any new elements that I create. My question is,
given an existing XML document to be processed how do I ascertain what
namespace prefix I should use for any new elements I add?
 
Surely, I don't have to interrogate the root element for all its xmlns
attributes, check their values and if they are namespaces I'm interested in,
store the prefixes away for later use or do I? Perhaps this isn't as painful
as I believe it might be, but it does seem like a long-winded approach to
achieve something that must be performed frequently.
 
Many thanks,
Scot