简体   繁体   English

如何使用php获取xml填充以推进表格

[英]How to get xml fill to advance table using php

I want to get xml from: http://sportsfeeds.bovada.lv/basic/ATP.xml to fill it to a special table like: http://sports.bovada.lv/sports-betting/tennis-atp.jsp 我想从以下网址获取xml: http//sportsfeeds.bovada.lv/basic/ATP.xml,将其填充到特殊表格中,例如: http : //sports.bovada.lv/sports-betting/tennis-atp.jsp

Current, I'm using DOMDocument to get it, but not ok, because it show not by order parent -> children. 当前,我正在使用DOMDocument来获取它,但是还不行,因为它没有按父->子顺序显示。

   Time | Name | Odds

         John   3.65
         David  5.65
         John   3.65
         David  5.65

I want show such as: 我想要显示如:

Time 时间

 3:50p | Name | Odds

         John   3.65
         David  5.65

 9:50a | Name | Odds
         John   3.65
         David  5.65

Like it 喜欢它

You can use XQuery to query your data. 您可以使用XQuery查询数据。

For instance: 例如:

import module namespace http = "http://expath.org/ns/http-client";

let $schedule := http:send-request((), "http://sportsfeeds.bovada.lv/basic/ATP.xml")[2]/Schedule
for $event-type in $schedule/EventType
order by $event-type/@TS descending
return <div>
  <h1>{string($event-type/@NAME)}</h1>
  {
      for $event in $event-type/Date/Event
      return <div>
          <h2>{string($event/@NAME)}</h2>
      </div>
  }
</div>

You can try this example live at http://www.zorba-xquery.com/html/demo#NBDPM72qey1mr4gSKRV1laxGnUc= Instruction on how to install the PHP XQuery extension are available at http://www.zorba-xquery.com/html/entry/2011/12/27/PHP_Meets_XQuery 您可以在http://www.zorba-xquery.com/html/demo#NBDPM72qey1mr4gSKRV1laxGnUc=上尝试此示例, 网址http://www.zorba-xquery.com/html,其中提供了有关如何安装PHP XQuery扩展的说明。 / entry / 2011/12/27 / PHP_Meets_XQuery

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM