xml 与javascript结合的问题解决方法
2024-09-06 12:42:54
供稿:网友
我想把html里面的title 动态绑定到一个xml
没成功 help me ,pls
如下
<html>
<XML ID="xmldso">
<?xml version="1.0"?>
<booklist>
<book>
<title>Straight Talk About Computersyyyyyyyyyy</title>
<isbn>72-80088-005</isbn>
</book>
<book>
<title>Straight Talk About Computersyyyyyyyyyy</title>
<isbn>72-80088-005</isbn>
</book>
</booklist>
</XML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<LABEL ID=title DATASRC=#xmldso DATAFLD="title"></LABEL>
<LABEL ID=title1 value="dff"></LABEL>
<SCRIPT LANGUAGE="JavaScript" for="xmldso">
<!--
//var df=xmldso.booklist.book("title");
//alert(df);
//alert(title1.value);
document.title="dd";
--here ,I want to document.title=df;
//-->
</SCRIPT>
<TABLE BORDER=1 DATASRC="#xmldso">
<THEAD>
<TR><TH>Title</TH> <TH>ISBN</TH></TR>
</THEAD>
<TBODY>
<TR><TD><DIV DATAFLD="title"></DIV></TD>
<TD><DIV DATAFLD="isbn"> </DIV></TD>
</TR>
</TBODY>
</TABLE>
<HR>
<XML ID="xmldso1" SRC="myXML.xml"> </XML>
<TABLE BORDER=1 DATASRC="#xmldso1">
<THEAD>
<TR><TH>书名</TH> <TH>出版号</TH></TR>
</THEAD>
<TBODY>
<TR><TD><DIV DATAFLD="title"></DIV></TD>
<TD><DIV DATAFLD="isbn"> </DIV></TD>
</TR>
</TBODY>
</TABLE>
</body>
</html>
myXML.xml 如下,其实这个没用,只不过为了完整性。
代码如下:
<?xml version="1.0" encoding="GBK"?>
<booklist>
<book>
<title>计算机技术</title>
<isbn>72-80088-005</isbn>
</book>
<book>
<title>电工技术</title>
<isbn>72-80081-082</isbn>
</book>
<book>
<title>计算机软件技术</title>
<isbn>72-80088-005</isbn>