Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何识别前进段和返回段?_Xml_Vb.net_Sabre - Fatal编程技术网

Xml 如何识别前进段和返回段?

Xml 如何识别前进段和返回段?,xml,vb.net,sabre,Xml,Vb.net,Sabre,以下回复来自Sabre TravelInvestureReadrq 从上面的回答中,我想确定返回段和前进段。 Rph=1,2为向前和向后 Rph=3.4,重新运行 我需要一种方法来识别这些,因为我正在阅读来自PNR的信息。 因此,我无法将其与任何其他请求进行比较 我不是在寻找一个代码来实现这一点,我是在问是否有人知道Sabre,是否有一种方法可以获得带有一些标识符的响应,以识别前进和返回,如MarriageGrp 试试这个。代码非常简单 using System; using System.Co

以下回复来自Sabre TravelInvestureReadrq

从上面的回答中,我想确定返回段和前进段。 Rph=1,2为向前和向后 Rph=3.4,重新运行

我需要一种方法来识别这些,因为我正在阅读来自PNR的信息。 因此,我无法将其与任何其他请求进行比较


我不是在寻找一个代码来实现这一点,我是在问是否有人知道Sabre,是否有一种方法可以获得带有一些标识符的响应,以识别前进和返回,如MarriageGrp

试试这个。代码非常简单

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq; 

namespace ConsoleApplication2
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);
            var results = doc.Descendants("Item")
                .Select(x => new { rph = x.Elements("RPH").FirstOrDefault().Value,
                                   flight = x.Descendants("FlightNumber").FirstOrDefault().Value
                })
                .ToList();

        }
    }
}
​

我知道这个问题可能很古老,但我看到了,我想我应该回答它,因为它可能会帮助其他人,以防你已经找到了解决它的方法,因为没有像MarriageGrp或任何其他类型的节点

这是我想要的流程

1. When a user searches, save the route information in a table say (Lhr->DXB->Lhr)
2. When the user picks an itinerary from the result and you submit the details to EnhancedAirbook, you get that ReservationItem node which is not grouped (like they were under OriginDestionationOptions in OTA_AILOW
3. The next step is pretty important. 
 a. Extract out all the destionations (in this case it would be DXB,LHR) into a variable say $paxDestLocations; Also we will have a variable say $FlightLegs - that will hold the Legs and the FlightSegments in each legs.

 If there are no more ReservationItems, then you are done. If there are more, then goto C.
 c. Let $totalSegments = count($reservationItems); 
    $usedSegmentsCounter = 0; // Will help know how much of ReservationItems we have used.
    Start a loop like the below..
    // $i will represent each leg of the flight.
    // $pL will equal total destinations
    // $pL = count($paxDestLocations);
    for ($i=0; $i<= $pL-1; $i++){
      $FlightLeg[$i]['FlightSegments'] = [];

      // We wana start counting from usedSegmentsCounter
      $s = $usedSegmentsCounter ;
      for ($j=$s; $j<=$totalSegments-1; $j++){
         // If we just started assigning segments for this leg, then just give the first segment to this leg, we will deal with the other segments in the else block..
         if(empty($FlightLeg[$i]['FlightSegments'])){
           $FlightLeg[$i]['FlightSegments'] = $reservationItems[$j];                                 
         }
         # Pick the segment..and just add it to the current leg
         else{
           $FlightLeg[$i]['FlightSegments'][count($FlightLeg[$i]['FlightSegments'])] = $reservationItems[$j];
         }

         // And below, we check if the current flight segment's destinationCode matched the destionationCode we are currently in..
         if($reservationItem[$j]['FlightSegment']['DestinationLocation']['LocationCode'] == $paxDestLocations[$i]){
             // We are done with the segments in this leg,
             break 2;
         }
      }

    }

    At the end of this loop, you will have an array of this Structure below:

    $FlightLeg = [
          // Leg 1
          [
            ['FlightSegents' = [
             [ // ReservationItem 1],
             [ // ReservationItem 2]
            ]
          ],
          // Leg 2
          [
            ['FlightSegents' = [
             [ // ReservationItem 1],
             [ // ReservationItem 2]
            ]
          ],
    ]

我知道您说过您不是在寻找代码,但我想使用上面的代码块更容易解释。

对不起。。这不是我要找的,我需要一种方法来识别前进段和返回段。我认为有一些命令可以使用sabrecommandllsrq来识别它,我不确定。我使用航班号作为从xml中获取一个属性的示例。使用相同的方法获取其他属性。每个航班号代表一个不同的航班段。这是我从Sabre得到的回应:没有真正的指示器,因为航段顺序用于区分“前进”和“返回”,但所使用的逻辑并不真正需要一个特定的“返回点”来进行行程。例如,从城市对a到B的行程是向前的,B到C的行程是返回的,但在这两者之间可能有其他目的地。已婚部分也不一定代表整个行程,因此它不是前进和返回的良好指示。
1. When a user searches, save the route information in a table say (Lhr->DXB->Lhr)
2. When the user picks an itinerary from the result and you submit the details to EnhancedAirbook, you get that ReservationItem node which is not grouped (like they were under OriginDestionationOptions in OTA_AILOW
3. The next step is pretty important. 
 a. Extract out all the destionations (in this case it would be DXB,LHR) into a variable say $paxDestLocations; Also we will have a variable say $FlightLegs - that will hold the Legs and the FlightSegments in each legs.

 If there are no more ReservationItems, then you are done. If there are more, then goto C.
 c. Let $totalSegments = count($reservationItems); 
    $usedSegmentsCounter = 0; // Will help know how much of ReservationItems we have used.
    Start a loop like the below..
    // $i will represent each leg of the flight.
    // $pL will equal total destinations
    // $pL = count($paxDestLocations);
    for ($i=0; $i<= $pL-1; $i++){
      $FlightLeg[$i]['FlightSegments'] = [];

      // We wana start counting from usedSegmentsCounter
      $s = $usedSegmentsCounter ;
      for ($j=$s; $j<=$totalSegments-1; $j++){
         // If we just started assigning segments for this leg, then just give the first segment to this leg, we will deal with the other segments in the else block..
         if(empty($FlightLeg[$i]['FlightSegments'])){
           $FlightLeg[$i]['FlightSegments'] = $reservationItems[$j];                                 
         }
         # Pick the segment..and just add it to the current leg
         else{
           $FlightLeg[$i]['FlightSegments'][count($FlightLeg[$i]['FlightSegments'])] = $reservationItems[$j];
         }

         // And below, we check if the current flight segment's destinationCode matched the destionationCode we are currently in..
         if($reservationItem[$j]['FlightSegment']['DestinationLocation']['LocationCode'] == $paxDestLocations[$i]){
             // We are done with the segments in this leg,
             break 2;
         }
      }

    }

    At the end of this loop, you will have an array of this Structure below:

    $FlightLeg = [
          // Leg 1
          [
            ['FlightSegents' = [
             [ // ReservationItem 1],
             [ // ReservationItem 2]
            ]
          ],
          // Leg 2
          [
            ['FlightSegents' = [
             [ // ReservationItem 1],
             [ // ReservationItem 2]
            ]
          ],
    ]