Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set namespace for QDomDocument

How to set namespace for QDomDocument

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 573 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kitfox
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kitfox
      wrote on last edited by
      #2

      Looks like I simply have to set the xmlns attribute in my root node.

      1 Reply Last reply
      0
      • JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        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).

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved