代码之家  ›  专栏  ›  技术社区  ›  psoares

明喻时间轴。XML文件有问题

  •  1
  • psoares  · 技术社区  · 14 年前

    http://www.simile-widgets.org/timeline/

    所以我试着遵循他们的教程,可以在这里找到: http://simile.mit.edu/wiki/How_to_Create_Timelines

    我遵循教程,所以代码是相同的,但它是这样的:

    <script>
       var tl;
    function onLoad() {
    var eventSource = new Timeline.DefaultEventSource();
    
    var bandInfos = [
    Timeline.createBandInfo({
        eventSource:    eventSource,
        date:           "Jun 28 2006 00:00:00 GMT",
    
        width:          "70%", 
        intervalUnit:   Timeline.DateTime.MONTH, 
        intervalPixels: 100
    }),
    Timeline.createBandInfo({
        eventSource:    eventSource,
        date:           "Jun 28 2006 00:00:00 GMT",
    
        width:          "30%", 
        intervalUnit:   Timeline.DateTime.YEAR, 
        intervalPixels: 200
    })
      ];
    bandInfos[1].syncWith = 0;
    bandInfos[1].highlight = true;
    
    tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
    Timeline.loadXML("test.xml", function(xml, url) { eventSource.loadXML(xml, url); });
    
    }
    
    var resizeTimerID = null;
    function onResize() {
    if (resizeTimerID == null) {
        resizeTimerID = window.setTimeout(function() {
            resizeTimerID = null;
            tl.layout();
        }, 500);
    }
    }
    
    </script>
    <body onload="onLoad();" onresize="onResize();">
    <div id="my-timeline" style="height: 150px; border: 1px solid #aaa"></div>
    </body>
    

     <?xml version="1.0" encoding="ISO-8859-1"?>
     <?xml-stylesheet type="text/css" href="/TBDBsite/media/timeline.css"?>
     <data>
    <event 
        start="May 28 2006 09:00:00 GMT"
        end="Jun 15 2006 09:00:00 GMT"
        isDuration="true"
        title="Writing Timeline documentation"
        image="http://simile.mit.edu/images/csail-logo.gif"
        >
        A few days to write some documentation for <a href="http://simile.mit.edu/timeline/">Timeline</a>.
        </event>
    
    <event 
        start="Jun 16 2006 00:00:00 GMT"
        end="Jun 26 2006 00:00:00 GMT"
        title="Friend's wedding"
        >
        I'm not sure precisely when my friend's wedding is.
        </event>
    
    <event 
        start="Aug 02 2006 00:00:00 GMT"
        title="Trip to Beijing"
        link="http://travel.yahoo.com/"
        >
        Woohoo!
        </event>
     </data>
    

    我在加载XML时遇到问题,我将其XML示例文件保存在模板所在的位置,但刷新页面时出现以下错误:

    未能从加载数据xml测试.xml
    找不到


    如果有人有更好的想法,使时间线,我也会感激。

    谢谢!

    2 回复  |  直到 14 年前
        1
  •  0
  •   pleasedontbelong    14 年前

    您尝试过xml的完整url路径吗?类似于 http://localhost/text.xml

        2
  •  3
  •   tardigradae    12 年前

    <data>