@ 2013-10-09T09:37:35Z <?php
$nodes = '<air:AirPricingInfo Key="3T" TotalPrice="EUR328.98" BasePrice="EUR191.00" ApproximateTotalPrice="EUR328.98" ApproximateBasePrice="EUR191.00" Taxes="EUR137.98" LatestTicketingTime="2013-10-15T23:59:00.000+00:00" PricingMethod="Auto" PlatingCarrier="KL" ProviderCode="1P">
<air:FareInfo Key="13T" FareBasis="TWKNL" PassengerTypeCode="ADT" SegmentOrigin="AMS" Origin="AMS" SegmentDestination="FCO" Destination="ROM" EffectiveDate="2013-10-08T17:49:20.621+02:00" Amount="NUC125.56">
<air:FareRuleKey FareInfoRef="13T" ProviderCode="1P">So05Ua7WWQ6LUnMVagmgWzIoZJ04F5ffjXmuoKjIAQzOW8SrBX6figwnZa5vZPwFnJN2p9gbxJQel+e1Y8YwIV8pQurxVP92</air:FareRuleKey>
</air:FareInfo>
<air:FareInfo Key="15T" FareBasis="TWKNL" PassengerTypeCode="ADT" SegmentOrigin="FCO" Origin="ROM" SegmentDestination="AMS" Destination="AMS" EffectiveDate="2013-10-08T17:49:20.630+02:00" Amount="NUC125.56">
<air:FareRuleKey FareInfoRef="15T" ProviderCode="1P">So05Ua7WWQ6LUnMVagmgWzIoZJ04F5fflvTVZQjlKmjOW8SrBX6figwnZa5vZPwFnJN2p9gbxJQel+e1Y8YwIV8pQurxVP92</air:FareRuleKey>
</air:FareInfo>
<air:BookingInfo BookingCode="T" FareInfoRef="13T" SegmentRef="1T"/>
<air:BookingInfo BookingCode="T" FareInfoRef="15T" SegmentRef="2T"/>
<air:PassengerType Code="ADT" BookingTravelerRef="1"/>
</air:AirPricingInfo>
<air:AirPricingInfo Key="17T" TotalPrice="EUR275.52" BasePrice="EUR144.00" ApproximateTotalPrice="EUR275.52" ApproximateBasePrice="EUR144.00" Taxes="EUR131.52" LatestTicketingTime="2013-10-15T23:59:00.000+00:00" PricingMethod="Auto" PlatingCarrier="KL" ProviderCode="1P">
<air:FareInfo Key="27T" FareBasis="TWKNL" PassengerTypeCode="CNN" SegmentOrigin="AMS" Origin="AMS" SegmentDestination="FCO" Destination="ROM" EffectiveDate="2013-10-08T17:49:20.653+02:00" Amount="NUC94.17">
<air:FareTicketDesignator Value="CH25"/>
<air:FareRuleKey FareInfoRef="27T" ProviderCode="1P">So05Ua7WWQ6LUnMVagmgWzIoZJ04F5ffjXmuoKjIAQzOW8SrBX6figwnZa5vZPwFnJN2p9gbxJQel+e1Y8YwIV8pQurxVP92</air:FareRuleKey>
</air:FareInfo>
<air:FareInfo Key="29T" FareBasis="TWKNL" PassengerTypeCode="CNN" SegmentOrigin="FCO" Origin="ROM" SegmentDestination="AMS" Destination="AMS" EffectiveDate="2013-10-08T17:49:20.655+02:00" Amount="NUC94.17">
<air:FareTicketDesignator Value="CH25"/>
<air:FareRuleKey FareInfoRef="29T" ProviderCode="1P">So05Ua7WWQ6LUnMVagmgWzIoZJ04F5fflvTVZQjlKmjOW8SrBX6figwnZa5vZPwFnJN2p9gbxJQel+e1Y8YwIV8pQurxVP92</air:FareRuleKey>
</air:FareInfo>
<air:BookingInfo BookingCode="T" FareInfoRef="27T" SegmentRef="1T"/>
<air:BookingInfo BookingCode="T" FareInfoRef="29T" SegmentRef="2T"/>
<air:PassengerType Code="CNN" BookingTravelerRef="2"/>
</air:AirPricingInfo>
<air:AirPricingInfo Key="31T" TotalPrice="EUR19.00" BasePrice="EUR19.00" ApproximateTotalPrice="EUR19.00" ApproximateBasePrice="EUR19.00" Taxes="EUR0.00" LatestTicketingTime="2013-10-15T23:59:00.000+00:00" PricingMethod="Auto" PlatingCarrier="KL" ProviderCode="1P">
<air:FareInfo Key="32T" FareBasis="TWKNL" PassengerTypeCode="INF" SegmentOrigin="AMS" Origin="AMS" SegmentDestination="FCO" Destination="ROM" EffectiveDate="2013-10-08T17:49:20.656+02:00" Amount="NUC12.55">
<air:FareTicketDesignator Value="IN90"/>
<air:FareRuleKey FareInfoRef="32T" ProviderCode="1P">So05Ua7WWQ6LUnMVagmgWzIoZJ04F5ffjXmuoKjIAQzOW8SrBX6figwnZa5vZPwFnJN2p9gbxJQel+e1Y8YwIV8pQurxVP92</air:FareRuleKey>
</air:FareInfo>
<air:FareInfo Key="34T" FareBasis="TWKNL" PassengerTypeCode="INF" SegmentOrigin="FCO" Origin="ROM" SegmentDestination="AMS" Destination="AMS" EffectiveDate="2013-10-08T17:49:20.657+02:00" Amount="NUC12.55">
<air:FareTicketDesignator Value="IN90"/>
<air:FareRuleKey FareInfoRef="34T" ProviderCode="1P">So05Ua7WWQ6LUnMVagmgWzIoZJ04F5fflvTVZQjlKmjOW8SrBX6figwnZa5vZPwFnJN2p9gbxJQel+e1Y8YwIV8pQurxVP92</air:FareRuleKey>
</air:FareInfo>
<air:BookingInfo BookingCode="T" FareInfoRef="32T" SegmentRef="1T"/>
<air:BookingInfo BookingCode="T" FareInfoRef="34T" SegmentRef="2T"/>
<air:PassengerType Code="INF" BookingTravelerRef="3"/>
</air:AirPricingInfo>';
$oMain = new DOMDocument();
$oMain->preserveWhiteSpace = false;
$oMain->formatOutput = true;
$oMain->loadXml('<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<air:AirCreateReservationReq xmlns:air="http://www.travelport.com/schema/air_v22_0" xmlns:com="http://www.travelport.com/schema/common_v19_0" AuthorizedBy="UAPI" TargetBranch="P7011033" ProviderCode="1P" Version="22">
<com:BillingPointOfSaleInfo OriginApplication="UAPI"/>
<com:BookingTraveler DOB="1993-03-23" TravelerType="ADT" Key="1" Gender="M">
<com:BookingTravelerName First="Edo" Last="Rivai" Prefix="Dhr."/>
<com:PhoneNumber Number="09007772228"/>
</com:BookingTraveler>
<com:BookingTraveler DOB="2008-05-05" TravelerType="CNN" Key="2" Gender="M">
<com:BookingTravelerName First="Bob" Last="stolk" Prefix="Dhr."/>
<com:PhoneNumber Number="09007772228"/>
</com:BookingTraveler>
<com:BookingTraveler DOB="2013-01-01" TravelerType="INF" Key="3" Gender="M">
<com:BookingTravelerName First="Jens" Last="Steenhuis" Prefix="Dhr."/>
<com:PhoneNumber Number="09007772228"/>
</com:BookingTraveler>
<air:AirPricingSolution Key="0T">
<air:AirSegment Key="1T" Group="0" Origin="AMS" Destination="FCO" Carrier="KL" FlightNumber="1609" ClassOfService="T" DepartureTime="2013-11-08T21:00:00.000+01:00" ArrivalTime="2013-11-08T23:10:00.000+01:00" ProviderCode="1P"/>
<air:AirSegment Key="2T" Group="1" Origin="FCO" Destination="AMS" Carrier="KL" FlightNumber="1608" ClassOfService="T" DepartureTime="2013-11-30T21:15:00.000+01:00" ArrivalTime="2013-11-30T23:40:00.000+01:00" ProviderCode="1P"/>
</air:AirPricingSolution>
<com:ActionStatus Type="TAW" TicketDate="2013-10-09" ProviderCode="1P"/>
</air:AirCreateReservationReq>
</soapenv:Body>
</soapenv:Envelope>');
$oAirPricingSolutionNode = $oMain->getElementsByTagName("AirPricingSolution")->item(0);
$oNodesEncapsulated = new DOMDocument();
$oNodesEncapsulated->preserveWhiteSpace = false;
//$oNodesEncapsulated->formatOutput = true;
$oNodesEncapsulated->loadXml('<root><air:wrapper xmlns:common_v19_0="http://www.travelport.com/schema/common_v19_0" xmlns:air="http://www.travelport.com/schema/air_v22_0" TransactionId="98C211960A076113466F7BECF086E1DC" ResponseTime="4399">'.$nodes.'</air:wrapper></root>');
# Select all air:PricingInfo nodes
$oAirPricingInfoNodes = $oNodesEncapsulated->getElementsByTagNameNs('http://www.travelport.com/schema/air_v22_0', 'AirPricingInfo');
# Check amount of nodes in selection
if( ! $oAirPricingInfoNodes->length){
return FALSE;
}
$iKey = 3;
# Loop over air:PricingInfo node selection
foreach($oAirPricingInfoNodes as $oAirPricingInfoNode) {
# Assign new key to the AirPricingNode
$oAirPricingInfoNode->setAttribute("Key", ($iKey++)."T");
# Remove all nodes except the fareInfo nodes
$oCurrentNode = $oAirPricingInfoNode->firstChild;
while(NULL !== $oCurrentNode) {
if (/*1 == $oCurrentNode->nodeType && */"air:FareInfo" != $oCurrentNode->nodeName) {
$oRemovable = $oCurrentNode;
$oCurrentNode = $oCurrentNode->nextSibling;
$oAirPricingInfoNode->removeChild($oRemovable);
// echo $oCurrentNode->nodeName . "\n";
} else {
$oCurrentNode = $oCurrentNode->nextSibling;
}
}
$oAirPricingSolutionNode->appendChild($oMain->importNode($oAirPricingInfoNode, TRUE));
}
$oSegmentNodes = $oAirPricingSolutionNode->getElementsByTagNameNs('http://www.travelport.com/schema/air_v22_0', 'AirSegment');
$oTravelerNodes = $oMain->getElementsByTagNameNs('http://www.travelport.com/schema/air_v22_0', 'BookingTraveler');
# Loop over the segments, and add BookingInfo nodes in accordance with the segments
foreach($oSegmentNodes as $oSegmentNode) {
foreach($oAirPricingInfoNodes as $oAirPricingInfoNode) {
// $oMatchingFareInfoNode;
foreach($oAirPricingInfoNode->getElementsByTagNameNs('http://www.travelport.com/schema/air_v22_0', 'FareInfo') as $oFareInfoNode) {
if ($oFareInfoNode->getAttribute("SegmentOrigin") == $oSegmentNode->getAttribute("Origin") &&
$oFareInfoNode->getAttribute("SegmentDestination") == $oSegmentNode->getAttribute("Destination")) {
$oMatchingFareInfoNode = $oFareInfoNode;
}
}
# Assing new key to the FareInfoNode
$oMatchingFareInfoNode->setAttribute("Key", ($iKey++)."T");
# Make the FareRuleKey's FareInfoRef match the Key of its parent (FareInfo)
$oAirPricingInfoNode->getElementsByTagNameNs('http://www.travelport.com/schema/air_v22_0', 'FareRuleKey')->item(0)->setAttribute("FareInfoRef", $oMatchingFareInfoNode->getAttribute("Key"));
# Create the BookingInfo element
$oBookingInfoNode = $oMain->createElement("air:BookingInfo");
$oBookingInfoNode->setAttribute("BookingCode", $oSegmentNode->getAttribute("ClassOfService"));
$oBookingInfoNode->setAttribute("FareInfoRef", $oMatchingFareInfoNode->getAttribute("Key"));
$oBookingInfoNode->setAttribute("SegmentRef", $oSegmentNode->getAttribute("Key"));
$oBookingInfoNodeNode = $oMain->importNode($oBookingInfoNode, TRUE);
$oAirPricingInfoNode->appendChild($oBookingInfoNodeNode);
# Add passenger type information if none exist yet.
if (0 == $oAirPricingInfoNode->getElementsByTagNameNs('http://www.travelport.com/schema/air_v22_0', 'PassengerType')->length) {
foreach($oTravelerNodes as $oTravelerNode) {
# Only add passenger types for the passengers whose type matches the passenger type in the matching fare info node
if ($oTravelerNode->getAttribute("TravelerType") == $oMatchingFareInfoNode->getAttribute("PassengerTypeCode")) {
# Create the passenger type node
$oPassengerTypeNode = $oMain->createElement("air:PassengerType");
$oPassengerTypeNode->setAttribute("Code", $oTravelerNode->getAttribute("TravelerType"));
$oPassengerTypeNode->setAttribute("BookingTravelerRef", $oTravelerNode->getAttribute("Key"));
$oBookingInfoNode->appendChild($oMain->importNode($oPassengerTypeNode, TRUE));
}
}
}
}
}
echo $oMain->saveXml() . "\n";
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Fatal error: Uncaught DOMException: Wrong Document Error in /in/9MeVh:121
Stack trace:
#0 /in/9MeVh(121): DOMNode->appendChild(Object(DOMElement))
#1 {main}
thrown in /in/9MeVh on line 121
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
37.67 ms | 401 KiB | 8 Q