我从Google API QPX Express收到输出。
如何格式化它们以使它们看起来更有条理?
感谢您的回复。
// Aircraft
foreach (var aircraft in result.Trips.Data.Aircraft)
{
Response.Output.Write(aircraft.Name + aircraft.Code);
}
// Airport
foreach (var airport in result.Trips.Data.Airport)
{
Response.Output.Write(airport.Name + " - " + airport.City);
}
foreach (var carrier in result.Trips.Data.Carrier)
{
Response.Output.Write(carrier.Name);
}
foreach (var trip in result.Trips.TripOption)
{
Response.Output.Write("Flight Number: " + trip.Slice.FirstOrDefault().Segment.FirstOrDefault().Flight.Number);
Response.Output.Write(" Duration: " + trip.Slice.FirstOrDefault().Duration);
Response.Output.Write(" Cabin: " + trip.Slice.FirstOrDefault().Segment.FirstOrDefault().Cabin);
Response.Output.Write(" Price: " + trip.Pricing.FirstOrDefault().BaseFareTotal.ToString());
}
答案 0 :(得分:0)
你可以做到
// Aircraft
Response.Output.Write("<h3>Aircrafts</h3>");
Response.Output.Write("<ul>");
foreach (var aircraft in result.Trips.Data.Aircraft)
{
Response.Output.Write("<li>" + aircraft.Name + " " + aircraft.Code + "</li>");
}
Response.Output.Write("</ul>");
会产生类似
的东西
<h3>Aircrafts</h3>
<ul>
<li>Airbus 123456</li>
<li>Airbus 123456</li>
<li>Airbus 123456</li>
<li>Airbus 123456</li>
</ul>
根据评论更新
或者使用Label1.Text
// Aircraft
foreach (var aircraft in result.Trips.Data.Aircraft)
{
Label1.Text += aircraft.Name + aircraft.Code;
}
答案 1 :(得分:0)
您可以使用https://datatables.net/将输出格式化为表格。