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. QDomDocument elementsByTagName and namespace
Forum Updated to NodeBB v4.3 + New Features

QDomDocument elementsByTagName and namespace

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 712 Views 2 Watching
  • 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.
  • mrdebugM Offline
    mrdebugM Offline
    mrdebug
    wrote on last edited by
    #1

    Hi I have to extrace the elments from a QDomDocument. The elements could have a node like
    "s:Body"
    or
    "SOAP-ENV:Body
    How can I extract the nodes searching "Body" without the namespace? Is there a way to have the namespace?

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    JonBJ 1 Reply Last reply
    0
    • mrdebugM mrdebug

      Hi I have to extrace the elments from a QDomDocument. The elements could have a node like
      "s:Body"
      or
      "SOAP-ENV:Body
      How can I extract the nodes searching "Body" without the namespace? Is there a way to have the namespace?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @mrdebug
      Assuming you've checked that elementsByTagName() does not return namespaced-items. Then QDomNodeList QDomDocument::elementsByTagNameNS(const QString &nsURI, const QString &localName) can be used if you know which namespace(s) you want to search.

      I'm not sure about a "get element by tag name across any namespace".

      1 Reply Last reply
      0
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #3

        My problem in the implementation of onvif protocol.
        A device responses with this document:

        <SOAP-ENV:Body>
        ..
        

        another device with

        <s:Body>
        ..
        

        so witch is the right way to have the "Body" element?

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        JonBJ 1 Reply Last reply
        0
        • mrdebugM mrdebug

          My problem in the implementation of onvif protocol.
          A device responses with this document:

          <SOAP-ENV:Body>
          ..
          

          another device with

          <s:Body>
          ..
          

          so witch is the right way to have the "Body" element?

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @mrdebug
          I assume you will find that the response starts with a declaration of what namespaces it is using and what "aliases" (like s:) it is going to use? That's how it works in XML documents, I don't know anything about devices and what they might do.

          Have you verified that elementsByTagName() does not return namespaced-items?

          1 Reply Last reply
          0
          • mrdebugM Offline
            mrdebugM Offline
            mrdebug
            wrote on last edited by
            #5

            The function elementsByTagName() works with "SOAP-ENV:Body" and "s:Body". But the problem is that on my desk I have two devices that uses two different namespaces. My problem is to manage the response for all the devices. I think that could be other devices with other different namespaces.
            Maybe the problem is the onvif / soap / xml protocol.
            This is the full response

            <?xml version="1.0" encoding="UTF-8"?>
            <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SOAP-ENV:Header></SOAP-ENV:Header>
            <SOAP-ENV:Body>
            <tds:GetCapabilitiesResponse>
            <tds:Capabilities>
            <tt:Device>
            <tt:XAddr>http://192.168.1.156:5000/onvif/device_service</tt:XAddr>
            <tt:Network>
            <tt:IPFilter>false</tt:IPFilter>
            <tt:ZeroConfiguration>false</tt:ZeroConfiguration>
            <tt:IPVersion6>false</tt:IPVersion6>
            <tt:DynDNS>false</tt:DynDNS>
            </tt:Network>
            <tt:System>
            <tt:DiscoveryResolve>false</tt:DiscoveryResolve>
            <tt:DiscoveryBye>false</tt:DiscoveryBye>
            <tt:RemoteDiscovery>true</tt:RemoteDiscovery>
            <tt:SystemBackup>false</tt:SystemBackup>
            <tt:SystemLogging>false</tt:SystemLogging>
            <tt:FirmwareUpgrade>false</tt:FirmwareUpgrade>
            <tt:SupportedVersions>
            <tt:Major>2</tt:Major>
            <tt:Minor>0</tt:Minor>
            </tt:SupportedVersions>
            <tt:Extension>
            <tt:HttpFirmwareUpgrade>false</tt:HttpFirmwareUpgrade>
            <tt:HttpSystemBackup>false</tt:HttpSystemBackup>
            <tt:HttpSystemLogging>false</tt:HttpSystemLogging>
            <tt:HttpSupportInformation>false</tt:HttpSupportInformation>
            </tt:Extension>
            </tt:System>
            <tt:IO>
            <tt:InputConnectors>2</tt:InputConnectors>
            <tt:RelayOutputs>2</tt:RelayOutputs>
            </tt:IO>
            </tt:Device>
            <tt:Media>
            <tt:XAddr>http://192.168.1.156:5000/onvif/media_service</tt:XAddr>
            <tt:StreamingCapabilities>
            <tt:RTPMulticast>true</tt:RTPMulticast>
            <tt:RTP_TCP>true</tt:RTP_TCP>
            <tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP>
            </tt:StreamingCapabilities>
            </tt:Media>
            <tt:PTZ>
            <tt:XAddr>http://192.168.1.156:5000/onvif/ptz_service</tt:XAddr>
            </tt:PTZ>
            <tt:Extension>
            <tt:DeviceIO>
            <tt:XAddr>http://192.168.1.156:5000/onvif/deviceio_service</tt:XAddr>
            <tt:VideoSources>1</tt:VideoSources>
            <tt:VideoOutputs>0</tt:VideoOutputs>
            <tt:AudioSources>0</tt:AudioSources>
            <tt:AudioOutputs>0</tt:AudioOutputs>
            <tt:RelayOutputs>0</tt:RelayOutputs>
            </tt:DeviceIO>
            </tt:Extension>
            </tds:Capabilities>
            </tds:GetCapabilitiesResponse>
            </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>
            
            

            Need programmers to hire?
            www.labcsp.com
            www.denisgottardello.it
            GMT+1
            Skype: mrdebug

            JonBJ 1 Reply Last reply
            0
            • mrdebugM mrdebug

              The function elementsByTagName() works with "SOAP-ENV:Body" and "s:Body". But the problem is that on my desk I have two devices that uses two different namespaces. My problem is to manage the response for all the devices. I think that could be other devices with other different namespaces.
              Maybe the problem is the onvif / soap / xml protocol.
              This is the full response

              <?xml version="1.0" encoding="UTF-8"?>
              <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
              <SOAP-ENV:Header></SOAP-ENV:Header>
              <SOAP-ENV:Body>
              <tds:GetCapabilitiesResponse>
              <tds:Capabilities>
              <tt:Device>
              <tt:XAddr>http://192.168.1.156:5000/onvif/device_service</tt:XAddr>
              <tt:Network>
              <tt:IPFilter>false</tt:IPFilter>
              <tt:ZeroConfiguration>false</tt:ZeroConfiguration>
              <tt:IPVersion6>false</tt:IPVersion6>
              <tt:DynDNS>false</tt:DynDNS>
              </tt:Network>
              <tt:System>
              <tt:DiscoveryResolve>false</tt:DiscoveryResolve>
              <tt:DiscoveryBye>false</tt:DiscoveryBye>
              <tt:RemoteDiscovery>true</tt:RemoteDiscovery>
              <tt:SystemBackup>false</tt:SystemBackup>
              <tt:SystemLogging>false</tt:SystemLogging>
              <tt:FirmwareUpgrade>false</tt:FirmwareUpgrade>
              <tt:SupportedVersions>
              <tt:Major>2</tt:Major>
              <tt:Minor>0</tt:Minor>
              </tt:SupportedVersions>
              <tt:Extension>
              <tt:HttpFirmwareUpgrade>false</tt:HttpFirmwareUpgrade>
              <tt:HttpSystemBackup>false</tt:HttpSystemBackup>
              <tt:HttpSystemLogging>false</tt:HttpSystemLogging>
              <tt:HttpSupportInformation>false</tt:HttpSupportInformation>
              </tt:Extension>
              </tt:System>
              <tt:IO>
              <tt:InputConnectors>2</tt:InputConnectors>
              <tt:RelayOutputs>2</tt:RelayOutputs>
              </tt:IO>
              </tt:Device>
              <tt:Media>
              <tt:XAddr>http://192.168.1.156:5000/onvif/media_service</tt:XAddr>
              <tt:StreamingCapabilities>
              <tt:RTPMulticast>true</tt:RTPMulticast>
              <tt:RTP_TCP>true</tt:RTP_TCP>
              <tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP>
              </tt:StreamingCapabilities>
              </tt:Media>
              <tt:PTZ>
              <tt:XAddr>http://192.168.1.156:5000/onvif/ptz_service</tt:XAddr>
              </tt:PTZ>
              <tt:Extension>
              <tt:DeviceIO>
              <tt:XAddr>http://192.168.1.156:5000/onvif/deviceio_service</tt:XAddr>
              <tt:VideoSources>1</tt:VideoSources>
              <tt:VideoOutputs>0</tt:VideoOutputs>
              <tt:AudioSources>0</tt:AudioSources>
              <tt:AudioOutputs>0</tt:AudioOutputs>
              <tt:RelayOutputs>0</tt:RelayOutputs>
              </tt:DeviceIO>
              </tt:Extension>
              </tds:Capabilities>
              </tds:GetCapabilitiesResponse>
              </SOAP-ENV:Body>
              </SOAP-ENV:Envelope>
              
              
              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #6

              @mrdebug said in QDomDocument elementsByTagName and namespace:

              The function elementsByTagName() works with "SOAP-ENV:Body" and "s:Body".

              Then in that case I don't follow your problem since you get BODY elements returned regardless of nname space, which seems to be what you want.

              Anyway, if you want to find the namespaces used that is what the line

              <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" ...

              defines. If you look at the one which uses <s:Body> you'll see that has s: defined in same line.

              TalklessT 1 Reply Last reply
              0
              • JonBJ JonB

                @mrdebug said in QDomDocument elementsByTagName and namespace:

                The function elementsByTagName() works with "SOAP-ENV:Body" and "s:Body".

                Then in that case I don't follow your problem since you get BODY elements returned regardless of nname space, which seems to be what you want.

                Anyway, if you want to find the namespaces used that is what the line

                <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" ...

                defines. If you look at the one which uses <s:Body> you'll see that has s: defined in same line.

                TalklessT Offline
                TalklessT Offline
                Talkless
                wrote on last edited by
                #7

                @JonB said in QDomDocument elementsByTagName and namespace:

                you get BODY elements returned regardless of nname space,

                NO, he explicitly said it works with explicit namespaces specifying SOAP-ENV:Body and s:Body, not just Body.

                I have same issue with same ONVIF protocol supporting devices...

                Alternative seems to use QXmlStreamReader, it's name() does return tag name without namespace, but you have to write much more imperative, manual code, comparing with QDomDocument.

                kkoehneK 1 Reply Last reply
                0
                • TalklessT Talkless

                  @JonB said in QDomDocument elementsByTagName and namespace:

                  you get BODY elements returned regardless of nname space,

                  NO, he explicitly said it works with explicit namespaces specifying SOAP-ENV:Body and s:Body, not just Body.

                  I have same issue with same ONVIF protocol supporting devices...

                  Alternative seems to use QXmlStreamReader, it's name() does return tag name without namespace, but you have to write much more imperative, manual code, comparing with QDomDocument.

                  kkoehneK Offline
                  kkoehneK Offline
                  kkoehne
                  Moderators
                  wrote on last edited by kkoehne
                  #8

                  @mrdebug , Qt 6.5 and onwards features new options for parsing, including the option QDomDocument::ParseOption::UseNamespaceProcessing . Have you tried this?

                  Director R&D, The Qt Company

                  TalklessT 1 Reply Last reply
                  0
                  • kkoehneK kkoehne

                    @mrdebug , Qt 6.5 and onwards features new options for parsing, including the option QDomDocument::ParseOption::UseNamespaceProcessing . Have you tried this?

                    TalklessT Offline
                    TalklessT Offline
                    Talkless
                    wrote on last edited by
                    #9

                    @kkoehne said in QDomDocument elementsByTagName and namespace:

                    @mrdebug , Qt 6.5 and onwards features new options for parsing, including the option QDomDocument::ParseOption::UseNamespaceProcessing . Have you tried this?

                    Thanks, didn't knew that! We still use Qt 5.15 though...

                    1 Reply Last reply
                    0

                    • Login

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