title: PHP - parsing xml which has namespace elements
body: <p>I read other posts and solutions, and they don't work for me - or perhaps I'm not understanding them well enough.</p>
  
  <p>I have a hp network scanner, and have a perl script that interacts through a series of transactions such that I can initiate a scan. I'm working to port that rather directly to php; more suitable for the server I want to run it on. Some transactions work, some don't. This is about one that doesn't.</p>
  
  <p>I took the XML from one of the queries and it won't successfully parse (or this is where I don't understand it well enough). I'm running php version 7.1.12, in case there is something related to that.</p>
  
  <p>my test outputs this:</p>
  
  <pre><code>&gt; php xmltest.php
  SimpleXMLElement Object
  (
  )
  object(SimpleXMLElement)#1 (0) {
  }
  &gt;
  </code></pre>
  
  <p>And if the xml is simpler (no name-space info I think), then the print_r() is quite verbose.</p>
  
  <p>And here is the full test script with some actual data to process
      
  
  <pre><code>error_reporting( E_ALL );
  ini_set('display_errors', 1);
  
  $test_1 = &lt;&lt;&lt;EOM
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope 
      xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
      xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
      xmlns:wst="http://schemas.xmlsoap.org/ws/2004/09/transfer"
      xmlns:mex="http://schemas.xmlsoap.org/ws/2004/09/mex"
      xmlns:wsdp="http://schemas.xmlsoap.org/ws/2006/02/devprof"
      xmlns:PNPX="http://schemas.microsoft.com/windows/pnpx/2005/10"
      xmlns:UNS1="http://www.microsoft.com/windows/test/testdevice/11/2005"
      xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0"
      xmlns:wprt="http://schemas.microsoft.com/windows/2006/08/wdp/print"
      xmlns:wscn="http://schemas.microsoft.com/windows/2006/08/wdp/scan"&gt;
      &lt;SOAP-ENV:Header&gt;
          &lt;wsa:To&gt;http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous&lt;/wsa:To&gt;
          &lt;wsa:Action&gt;http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse&lt;/wsa:Action&gt;
          &lt;wsa:MessageID&gt;urn:uuid:fec6e42d-5356-1f69-9c3a-001f2927cf33&lt;/wsa:MessageID&gt;
          &lt;wsa:RelatesTo&gt;urn:uuid:704ccde5-6861-415d-bd65-31dd9d7a8b98&lt;/wsa:RelatesTo&gt;
      &lt;/SOAP-ENV:Header&gt;
      &lt;SOAP-ENV:Body&gt;
          &lt;mex:Metadata&gt;
              &lt;mex:MetadataSection Dialect="http://schemas.xmlsoap.org/ws/2006/02/devprof/ThisDevice"&gt;
                  &lt;wsdp:ThisDevice&gt;
                      &lt;wsdp:FriendlyName xml:lang="en"&gt;Printer (HP Color LaserJet CM1312nfi MFP)&lt;/wsdp:FriendlyName&gt;
                      &lt;wsdp:FirmwareVersion&gt;20140625&lt;/wsdp:FirmwareVersion&gt;
                      &lt;wsdp:SerialNumber&gt;CNB885H665&lt;/wsdp:SerialNumber&gt;
                  &lt;/wsdp:ThisDevice&gt;
              &lt;/mex:MetadataSection&gt;
              &lt;mex:MetadataSection Dialect="http://schemas.xmlsoap.org/ws/2006/02/devprof/ThisModel"&gt;
                  &lt;wsdp:ThisModel&gt;
                      &lt;wsdp:Manufacturer xml:lang="en"&gt;HP&lt;/wsdp:Manufacturer&gt;
                      &lt;wsdp:ManufacturerUrl&gt;http://www.hp.com/&lt;/wsdp:ManufacturerUrl&gt;
                      &lt;wsdp:ModelName xml:lang="en"&gt;HP Color LaserJet CM1312nfi MFP&lt;/wsdp:ModelName&gt;
                      &lt;wsdp:ModelNumber&gt;CM1312nfi MFP&lt;/wsdp:ModelNumber&gt;
                      &lt;wsdp:PresentationUrl&gt;http://192.168.1.20:80/&lt;/wsdp:PresentationUrl&gt;
                      &lt;PNPX:DeviceCategory&gt;Printers&lt;/PNPX:DeviceCategory&gt;
                  &lt;/wsdp:ThisModel&gt;
              &lt;/mex:MetadataSection&gt;
              &lt;mex:MetadataSection Dialect="http://schemas.xmlsoap.org/ws/2006/02/devprof/Relationship"&gt;
                  &lt;wsdp:Relationship Type="http://schemas.xmlsoap.org/ws/2006/02/devprof/host"&gt;
                      &lt;wsdp:Hosted&gt;
                          &lt;wsa:EndpointReference&gt;
                              &lt;wsa:Address&gt;http://192.168.1.20:3910/&lt;/wsa:Address&gt;
                              &lt;wsa:ReferenceProperties&gt;
                                  &lt;UNS1:ServiceIdentifier&gt;uri:prn&lt;/UNS1:ServiceIdentifier&gt;
                              &lt;/wsa:ReferenceProperties&gt;
                          &lt;/wsa:EndpointReference&gt;
                          &lt;wsdp:Types&gt;wprt:PrinterServiceType&lt;/wsdp:Types&gt;
                          &lt;wsdp:ServiceId&gt;uri:1cd4F16e-7c8a-a7a0-3797-00145a8827ce&lt;/wsdp:ServiceId&gt;
                          &lt;PNPX:CompatibleId&gt;http://schemas.microsoft.com/windows/2006/08/wdp/print/PrinterServiceType&lt;/PNPX:CompatibleId&gt;
                      &lt;/wsdp:Hosted&gt;
                  &lt;/wsdp:Relationship&gt;
              &lt;/mex:MetadataSection&gt;
          &lt;/mex:Metadata&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  EOM;
  
  $myxml1 = simplexml_load_string($test_1);
  print_r($myxml1);
  var_dump($myxml1);
  exit;
  ?&gt;
  </code></pre>
  
  <p>There are several parameters nestled in there that I want to pull out. One, for instance is:</p>
  
  <pre><code>&lt;wsa:Address&gt;http://192.168.1.20:3910/&lt;/wsa:Address&gt;
  </code></pre>
  
  <p>Can you help me close my knowledge gap on how to access this parameter?</p>
  
  <p>thanks!</p>