SimpleXML SOAP response Namespace issues

前端 未结 2 479
野性不改
野性不改 2020-11-29 10:44

After spending SEVERAL frustrated hours on this I am asking for your help.

I am trying to get the content of particular nodes from a SOAP response.

The resp

2条回答
  •  自闭症患者
    2020-11-29 11:26

    You have to use SimpleXMLElement::children(), though at this point it would probably be easier to use XPath.

    
    
        
            
                
                
                    
                        24
                        The+client+order+number+3002254+is+already+in+use
                    
                    
                        1
                        Aborting
                    
                
            
        
    
    XML;
    
        $XmlArray   = new SimpleXMLElement($XmlStr);
    
        $t = $XmlArray->children("env", true)->Body->
            children("ns1", true)->PlaceOrderResponse->
            children()->ErrorArray->Error;
        foreach ($t as $error) {
            echo $error->ErrorCode, " " , $error->ErrorText, "
    "; }

    gives:

    24 The+client+order+number+3002254+is+already+in+use
    1 Aborting
    

提交回复
热议问题