How to set namespace for QDomDocument
-
I would like to create an XML document where every element will be part of the same namespace. Is there a way to set up my QDomDocument so that all the nodes I append to it are by default part of that namespace, or do I need to pass in the namespace for every element and attribute I create?
-
Do you mean you want to change the default namespace of the document so that your nodes do not have any
<prefix:...>
when you view the document, or do you mean you're happy to have the namespace specified in the nodes but you just don't want to have to include it explicitly every time you want to create a node?EDIT Your new post crossed with my reply. You seem to want the first approach, so yes you need to set your document's (root node's)
xmlns
. See also https://stackoverflow.com/questions/24699413/how-to-declare-namespaces-with-qdomdocument, which never got a response but shows alternatives for achieving (actually, I'm not sure that's relevant to your simple case).