<?php // used namespaces, the keys do NOT need to match the prefixes in the XML. $xmlns = [ 'soap' => 'http://schemas.xmlsoap.org/soap/envelope/', 'eb' => 'http://www.ebxml.org/namespaces/messageHeader', 'sec' => 'http://schemas.xmlsoap.org/ws/2002/12/secext' ]; $document = new DOMDocument(); $document->loadXML(getSoapXmlString()); $xpath = new DOMXpath($document); // register your aliases for the namespaces foreach ($xmlns as $alias => $uri) { $xpath->registerNamespace($alias, $uri); } $token = $xpath->evaluate( 'string(//sec:Security/sec:BinarySecurityToken)' ); var_dump($token); function getSoapXmlString() { return <<<'XML' <?xml version="1.0" encoding="UTF-8"?> <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:Header> <eb:MessageHeader xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" eb:version="1.0" soap-env:mustUnderstand="1"> <eb:From> <eb:PartyId eb:type="URI">Sabre_API</eb:PartyId> </eb:From> <eb:To> <eb:PartyId eb:type="URI">Agency</eb:PartyId> </eb:To> <eb:ConversationId>2021.01.DevStudio</eb:ConversationId> <eb:Service eb:type="sabreXML">Session</eb:Service> <eb:Action>TokenCreateRS</eb:Action> <eb:MessageData> <eb:MessageId>1913771794839350290</eb:MessageId> <eb:Timestamp>2023-02-23T22:04:43</eb:Timestamp> </eb:MessageData> </eb:MessageHeader> <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"> <wsse:BinarySecurityToken valueType="String" EncodingType="wsse:Base64Binary">T1RLAQLASo74A7olKG7QnepeFqs19UHX+0Cds9QiDZoYfu677xC3Vkr9a+OcQhutjPL4atVMAADQRtHIXdehGg/0OVuPdia/0cM233jFDvyJJHgJHC3o8gV2ssS63b4Y0lgCG59SiG4tmEcqAXcYAMlnq+wJ4TfsOIDFwYdP+D0peSEFBM/m3EyOUqc4idJ+vO4S7xENCeQ7UX4YVKjVLJs788omPDbSIRNo85KQ5QxRprldV0jucJpAtbNfs1DrMHFqNIPyg0CpVpgXILkFx0azkcAuvmbHMHLqqO13WJEOhsG0KDBhBhRn8CwoCgD9foXL24W6yGu8Ecm0Fzvb/MuAjuYm9s48yg**</wsse:BinarySecurityToken> </wsse:Security> </soap-env:Header> <soap-env:Body> <sws:TokenCreateRS xmlns:sws="http://webservices.sabre.com" Version="1.0.0"> <sws:Success/> </sws:TokenCreateRS> </soap-env:Body> </soap-env:Envelope> XML; }
You have javascript disabled. You will not be able to edit any code.