//////////貓頭鷹傳送帶重複滑塊 - 外部XML驅動
更新 - 的問題之一是在線路81上
昏暗nodes2作爲XmlNodeList中= xmlDoc2.DocumentElement.SelectNodes(「/ xml/books/book「)
我在=符號後沒有使用xmlDoc2。
//////////
我不斷嘗試在XML來讀取外部源時,得到一個重複的貓頭鷹轉盤。我想看2個不同的輪播。
我確定我們有不同的ID,並且我們正在給他們打電話。 XML在模式不同的時候都是有效的,我們只是循環遍歷這些材料。我也嘗試了2個不同版本的jquery 2.0和1.12從大G.
如果我用mURL2替換第一個XML字符串mURL,它會顯示替換列表兩次,這意味着我以某種方式覆蓋了我的值。
實施例:http://images2.toledolibrary.org/imagewall/_new/2016%20-%20OPAC/opac.aspx
<%@ Page Language="VB" %>
<%@ Import Namespace=System.Web.UI %>
<%@ Import Namespace=System.Xml %>
<%@ Import Namespace=System.IO %>
<!DOCTYPE html>
<script runat="server">
Sub Page_Load()
If Not Page.IsPostBack Then
Dim mURL As String
Dim mURL2 As String
mURL = "http://bookdb.nextgoodbook.com/v3/api/booklist/lid/43604001/nlid/23581/format/xml"
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(mURL)
Dim nodes As XmlNodeList = xmlDoc.DocumentElement.SelectNodes("/xml/books/book")
Dim pId As String = ""
Dim pIsbn As String = ""
Dim pTitle As String = ""
Dim pAuthor As String = ""
Dim pTitleCk As String = ""
Dim intCount As Integer = 0
ltlBooks.Text = ltlBooks.Text & ("<div id=owl-carousel class=owl-carousel owl-theme>")
For Each node As XmlNode In nodes
pId = node.SelectSingleNode("id").InnerText
pIsbn = node.SelectSingleNode("isbn").InnerText
pTitle = node.SelectSingleNode("title").InnerText
pAuthor = node.SelectSingleNode("author").InnerText
If (pTitle = pTitleCk) Then
Else
<%-- Response.Write(pId & "<br>" & pIsbn & "<br>" & pTitle & "<br>" & pAuthor & "<br><br>") --%>
ltlBooks.Text = ltlBooks.Text & ("<div class=item><a href=http://bookdb.nextgoodbook.com/borrow/at/cd43303c6a75acf5b2e4e739a060de31/" & pIsbn & ">" & "<img width=100% src=http://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=TOL67950&Password=CC11779&Return=1&Type=L&Value=" & pIsbn & " /></a></div>")
intCount = intCount + 1
End If
pTitleCk = pTitle
Next
ltlBooks.Text = ltlBooks.Text & ("</div>")
<%-- ----------------- --%>
mURL2 = "http://bookdb.nextgoodbook.com/v3/api/custom/lid/43604001/nlid/16461/format/xml"
<%-- kids
mURL2 = "http://bookdb.nextgoodbook.com/v3/api/custom/lid/43604001/nlid/26575/format/xml"
--%>
Dim xmlDoc2 As New XmlDocument()
xmlDoc2.Load(mURL2)
Dim nodes2 As XmlNodeList = xmlDoc.DocumentElement.SelectNodes("/xml/books/book")
Dim pId2 As String = ""
Dim pIsbn2 As String = ""
Dim pTitle2 As String = ""
Dim pAuthor2 As String = ""
Dim pTitleCk2 As String = ""
Dim intCount2 As Integer = 0
ltlBooks2.Text = ltlBooks2.Text & ("<div id=owl-carousel2 class=owl-carousel2 owl-theme>")
For Each dvdnode As XmlNode In nodes2
pId2 = dvdnode.SelectSingleNode("id").InnerText
pIsbn2 = dvdnode.SelectSingleNode("isbn").InnerText
pTitle2 = dvdnode.SelectSingleNode("title").InnerText
pAuthor2 = dvdnode.SelectSingleNode("author").InnerText
If (pTitle2 = pTitleCk2) Then
Else
ltlBooks2.Text = ltlBooks2.Text & ("<div class=item><a href=http://bookdb.nextgoodbook.com/borrow/at/cd43303c6a75acf5b2e4e739a060de31/" & pIsbn2 & ">" & "<img width=100% src=http://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=TOL67950&Password=CC11779&Return=1&Type=L&Value=" & pIsbn2 & " /></a></div>")
intCount2 = intCount2 + 1
End If
pTitleCk2 = pTitle2
Next
ltlBooks2.Text = ltlBooks2.Text & ("</div>")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DVD Carousel</title>
<meta charset="utf-8">
<meta name="viewport" content="">
<meta name="description" content="">
<meta name="author" content="">
<meta name="keywords" content="">
<!-- Important Owl stylesheet -->
<link rel="stylesheet" href="owl.carousel.css">
<!-- jQuery 1.7+ -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<!--
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
-->
<!-- Include js plugin -->
<script src="owl.carousel.js"></script>
<script>
$(document).ready(function() {
$('#owl-carousel, #owl-carousel2').owlCarousel({
margin:10,
loop:true,
autoWidth:true,
items:4,
autoplay:true
})
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="header">NEW DVDS</div>
<asp:Literal ID="ltlBooks2" runat="server"></asp:Literal>
<div class="header2">WEEKLY STAFF PICKS</div>
<asp:Literal ID="ltlBooks" runat="server"></asp:Literal>
</div>
</form>
<div id="footer"><img src="logo.png" /></div>
</body>
</html>