将XML记录解析为多个选项卡(使用PHP或jQuery)

将XML记录解析为多个选项卡(使用PHP或jQuery),php,jquery,parsing,tabs,xml-parsing,Php,Jquery,Parsing,Tabs,Xml Parsing,我现在在一个DJ的网站上工作,他用GigaTools做他的演唱会。 目前,我已经用php解析了GigaTools提要(xml),并在网站上显示了一个表。但这仅限于显示的最大记录数(12),因为这正是网站上适合的 这是我当前使用的脚本: <?php $gigatools = simplexml_load_file('http://gigs.gigatools.com/user/MikeRavelli.xml'); echo "<table id='gig

我现在在一个DJ的网站上工作,他用GigaTools做他的演唱会。 目前,我已经用php解析了GigaTools提要(xml),并在网站上显示了一个表。但这仅限于显示的最大记录数(12),因为这正是网站上适合的

这是我当前使用的脚本:

      <?php 

    $gigatools = simplexml_load_file('http://gigs.gigatools.com/user/MikeRavelli.xml');
    echo "<table id='gigs_parse'>\n";

    for($i = 0; $i < 12; $i++) {
      $event = $gigatools->event[$i];
      $day=$event->day;
      $month=$event->month;
      $name=$event->name;
      $venue=$event->venue;
      $city=$event->city;
      $country=$event->country;

      if($month == 1){
        $maand = 'JAN';
      } else if($month == 2){
        $maand = 'FEB';
      } else if($month == 3){
        $maand = 'MAR';
      } else if($month == 4){
        $maand = 'APR';
      } else if($month == 5){
        $maand = 'MAY';
      } else if($month == 6){
        $maand = 'JUN';
      } else if($month == 7){
        $maand = 'JUL';
      } else if($month == 8){
        $maand = 'AUG';
      } else if($month == 9){
        $maand = 'SEP';
      } else if($month == 10){
        $maand = 'OCT';
      } else if($month == 11){
        $maand = 'NOV';
      } else if($month == 12){
        $maand = 'DEC';
      }

      echo "<tr class='row'><td class='date'><span>",$day,"</span><br/>",$maand,"</td>\n";
      echo "<td class='party'><a href='",$url,"' target='_blank'>",$name,"</td>\n";
      echo "<td class='location'>",$venue,", ",$city,", ",$country,"</td>\n";
    }
    echo "</table>";
    ?>
您可以使用

你可以找到一个非常简单的例子。更改脚本以生成这样的表应该很容易

<div id="tabs">
<ul>
    <li><a href="#tabs-1">First</a></li>
    <li><a href="#tabs-2">Second</a></li>
    <li><a href="#tabs-3">Third</a></li>
</ul>
<div id="tabs-1">
    <p>First tab contents</p>
</div>
<div id="tabs-2">
    <p>Second tab contents</p>
</div>
<div id="tabs-3">
    <p>Third tab contents</p>
</div>
</div>

第一个选项卡内容

第二个选项卡内容

第三个选项卡内容

之后,您必须在文档的
中添加JQuery UI所需的所有js和css:

<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.0.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.tabs.js"></script>
<link rel="stylesheet" href="../demos.css">

最后,只需调用实际创建选项卡的函数

<script>
$(function() {
    $( "#tabs" ).tabs();
});
</script>

$(函数(){
$(“#制表符”).tabs();
});
您可以使用

你可以找到一个非常简单的例子。更改脚本以生成这样的表应该很容易

<div id="tabs">
<ul>
    <li><a href="#tabs-1">First</a></li>
    <li><a href="#tabs-2">Second</a></li>
    <li><a href="#tabs-3">Third</a></li>
</ul>
<div id="tabs-1">
    <p>First tab contents</p>
</div>
<div id="tabs-2">
    <p>Second tab contents</p>
</div>
<div id="tabs-3">
    <p>Third tab contents</p>
</div>
</div>

第一个选项卡内容

第二个选项卡内容

第三个选项卡内容

之后,您必须在文档的
中添加JQuery UI所需的所有js和css:

<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.0.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.tabs.js"></script>
<link rel="stylesheet" href="../demos.css">

最后,只需调用实际创建选项卡的函数

<script>
$(function() {
    $( "#tabs" ).tabs();
});
</script>

$(函数(){
$(“#制表符”).tabs();
});

谢谢你,伙计!正在搜索用于Gigatools的PHP XML解析器

我对PHP也是新手,但它不是更好吗

<?php 

    $feed = 'http://gigs.gigatools.com/user/MikeRavelli2.xml';
    $gigatools = simplexml_load_file($feed)or
          die ("Fehler beim Laden des Feeds: ".$feed."\n");;
    $countgigs = count($gigatools->event);
    echo "<table id='gigs_parse'>\n";
    if ($countgigs > 12) {
        $gigs = 12;
    } else {
        $gigs = $countgigs;
    }

    for($i = 0; $i < $gigs; $i++) {
      $event = $gigatools->event[$i];
      $day=$event->day;
      $month=$event->month;
      $name=$event->name;
      $venue=$event->venue;
      $city=$event->city;
      $country=$event->country;

      if($month == 1){
        $maand = 'JAN';
      } else if($month == 2){
        $maand = 'FEB';
      } else if($month == 3){
        $maand = 'MAR';
      } else if($month == 4){
        $maand = 'APR';
      } else if($month == 5){
        $maand = 'MAY';
      } else if($month == 6){
        $maand = 'JUN';
      } else if($month == 7){
        $maand = 'JUL';
      } else if($month == 8){
        $maand = 'AUG';
      } else if($month == 9){
        $maand = 'SEP';
      } else if($month == 10){
        $maand = 'OCT';
      } else if($month == 11){
        $maand = 'NOV';
      } else if($month == 12){
        $maand = 'DEC';
      }

      echo "<tr class='row'><td class='date'><span>",$day,"</span><br/>",$maand,"</td>\n";
      echo "<td class='party'><a href='",$url,"' target='_blank'>",$name,"</td>\n";
      echo "<td class='location'>",$venue,", ",$city,", ",$country,"</td>\n";
    }
    echo "</table>";
    ?>

谢谢你,伙计!正在搜索用于Gigatools的PHP XML解析器

我对PHP也是新手,但它不是更好吗

<?php 

    $feed = 'http://gigs.gigatools.com/user/MikeRavelli2.xml';
    $gigatools = simplexml_load_file($feed)or
          die ("Fehler beim Laden des Feeds: ".$feed."\n");;
    $countgigs = count($gigatools->event);
    echo "<table id='gigs_parse'>\n";
    if ($countgigs > 12) {
        $gigs = 12;
    } else {
        $gigs = $countgigs;
    }

    for($i = 0; $i < $gigs; $i++) {
      $event = $gigatools->event[$i];
      $day=$event->day;
      $month=$event->month;
      $name=$event->name;
      $venue=$event->venue;
      $city=$event->city;
      $country=$event->country;

      if($month == 1){
        $maand = 'JAN';
      } else if($month == 2){
        $maand = 'FEB';
      } else if($month == 3){
        $maand = 'MAR';
      } else if($month == 4){
        $maand = 'APR';
      } else if($month == 5){
        $maand = 'MAY';
      } else if($month == 6){
        $maand = 'JUN';
      } else if($month == 7){
        $maand = 'JUL';
      } else if($month == 8){
        $maand = 'AUG';
      } else if($month == 9){
        $maand = 'SEP';
      } else if($month == 10){
        $maand = 'OCT';
      } else if($month == 11){
        $maand = 'NOV';
      } else if($month == 12){
        $maand = 'DEC';
      }

      echo "<tr class='row'><td class='date'><span>",$day,"</span><br/>",$maand,"</td>\n";
      echo "<td class='party'><a href='",$url,"' target='_blank'>",$name,"</td>\n";
      echo "<td class='location'>",$venue,", ",$city,", ",$country,"</td>\n";
    }
    echo "</table>";
    ?>

我已经看过了,但问题是我必须预定义选项卡。我想要的是,脚本将自动创建选项卡,这取决于我从xml提要的解析中获得的记录数。您知道事件的数量,因此选项卡的数量将是ceil(numEvents/12)。现在您已经知道了选项卡的数量,只需重复当前循环更多次。谢谢您的回答!我调整了我的php脚本并添加了jQueryUI选项卡。现在我要做的就是设计它;)我已经看过了,但问题是我必须预先定义标签。我想要的是,脚本将自动创建选项卡,这取决于我从xml提要的解析中获得的记录数。您知道事件的数量,因此选项卡的数量将是ceil(numEvents/12)。现在您已经知道了选项卡的数量,只需重复当前循环更多次。谢谢您的回答!我调整了我的php脚本并添加了jQueryUI选项卡。现在我要做的就是设计它;)