簡體   English   中英

用於在頁面加載時讀取和輸出XML文件的JavaScript代碼段?

[英]JavaScript snippet to read and output XML file on page load?

大家好,希望我能有所幫助。 在此將XML文件包含書籍清單,每本書具有唯一的ID和數字值,以指示是否將其簽出。 我需要一個JavaScript代碼段,該代碼段在頁面加載並顯示XML文件的內容之后請求XML文件。

XML文件如下所示:

    <?xml version="1.0" encoding="UTF-8" ?>
    <response>
      <library name="My Library">
        <book id="1" checked-out="1">
          <authors>
            <author>John Resig</author>
          </authors>
          <title>Pro JavaScript Techniques (Pro)</title>
          <isbn-10>1590597273</isbn-10>
        </book>
        <book id="2" checked-out="0">
          <authors>
            <author>Erich Gamma</author>
            <author>Richard Helm</author>
            <author>Ralph Johnson</author>
            <author>John M. Vlissides</author>
          </authors>
          <title>Design Patterns: Elements of Reusable Object-Oriented Software</title>
          <isbn-10>0201633612</isbn-10>
        </book>
        ...
      </library>
    </response>

希望有任何幫助!

這完全取決於您希望結果如何復雜。 如果您想從該XML文件創建可排序的表,並且喜歡YUI,則可以使用一個YUI2小部件來解決這個問題。 這是一個示例: http : //developer.yahoo.com/yui/examples/datatable/dt_xhrpostxml.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM