Important: Please read the Qt Code of Conduct -

How to get namespaces in the root QDomElement?

  • most xml like to declare namespaces in the root element like this:

    <root xmlns="a" xmlns:x="b">
        <x:e />

    but call QDomDocument::setContent with setting namespaceProcessing to true will result unexpected behavior:

    rootElem.prefix(); // ""
    rootElem.namespaceURI(); // "a"
    eElem.prefix(); // "x"
    eElem.namespaceURI(); // "b"
    rootElem.attributes(); // empty map!!!  can't even parse manually

    Is there an easy way to get all namespaces in a QDomElement?


Log in to reply