3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $writer = new SimpleXMLElement('<?xml version="1.0"?><MessageHeader><MessageThreadId>0000000022</MessageThreadId><MessageId>000000002201</MessageId><MessageSender><PartyId>PADPIDA2010071901R</PartyId><PartyName><FullName>RHAPSODY INTERNATIONAL, INC.</FullName></PartyName><TradingName>Premier Extra</TradingName></MessageSender><MessageRecipient><PartyId>SWAPFORSOCIETYID</PartyId><PartyName><FullName>SWAPFORSOCIETYNAME</FullName></PartyName></MessageRecipient><MessageCreatedDateTime>2014-06-30T09:35:57</MessageCreatedDateTime></MessageHeader>'); $messagerecipient = $writer->xpath('MessageRecipient'); //foreach($messagerecipient as $data){ $messagerecipient[0]->PartyID = '1234'; //} $output = $writer->asXML(); echo $output; var_dump($messagerecipient); ?>
Output for 5.1.3 - 7.1.0
<?xml version="1.0"?> <MessageHeader><MessageThreadId>0000000022</MessageThreadId><MessageId>000000002201</MessageId><MessageSender><PartyId>PADPIDA2010071901R</PartyId><PartyName><FullName>RHAPSODY INTERNATIONAL, INC.</FullName></PartyName><TradingName>Premier Extra</TradingName></MessageSender><MessageRecipient><PartyId>SWAPFORSOCIETYID</PartyId><PartyName><FullName>SWAPFORSOCIETYNAME</FullName></PartyName><PartyID>1234</PartyID></MessageRecipient><MessageCreatedDateTime>2014-06-30T09:35:57</MessageCreatedDateTime></MessageHeader> array(1) { [0]=> object(SimpleXMLElement)#2 (3) { ["PartyId"]=> string(16) "SWAPFORSOCIETYID" ["PartyName"]=> object(SimpleXMLElement)#3 (1) { ["FullName"]=> string(18) "SWAPFORSOCIETYNAME" } ["PartyID"]=> string(4) "1234" } }
Output for 5.0.0 - 5.1.2
<?xml version="1.0"?> <MessageHeader><MessageThreadId>0000000022</MessageThreadId><MessageId>000000002201</MessageId><MessageSender><PartyId>PADPIDA2010071901R</PartyId><PartyName><FullName>RHAPSODY INTERNATIONAL, INC.</FullName></PartyName><TradingName>Premier Extra</TradingName></MessageSender><MessageRecipient><PartyId>SWAPFORSOCIETYID</PartyId><PartyName><FullName>SWAPFORSOCIETYNAME</FullName></PartyName></MessageRecipient><MessageCreatedDateTime>2014-06-30T09:35:57</MessageCreatedDateTime></MessageHeader> array(1) { [0]=> object(SimpleXMLElement)#2 (2) { ["PartyId"]=> string(16) "SWAPFORSOCIETYID" ["PartyName"]=> object(SimpleXMLElement)#3 (1) { ["FullName"]=> string(18) "SWAPFORSOCIETYNAME" } } }
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/Qp0qF on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/Qp0qF on line 2