老大出现了,,有些太激动了,,我要在js里给这个conent分页呀。

解决方案 »

  1.   

    document是HTML的DOM对象,不是XML的DOM, HTML里并没有content,所以是0。
      

  2.   

    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <HTML>
    <HEAD>
    <script language="javascript"><xsl:text>
    var maxNum=<xsl:value-of select="count(/topic/content)"/>;
    </xsl:text></script>
    <script language="javascript" src="aaaa.js"></script>
    aaaa.js中取maxNum
      

  3.   

    ......
    <BODY ...>
    <script>window.maxNum=<xsl:value-of select="count(...)"></script>
    ......
      

  4.   

    根据你的 浏览器对这个xml文件进行解析,ie可用dom解析,
    给你点代码
     //全局变量 var global_IsIE = false;//浏览器是否为IE   if (window.ActiveXObject)   {      global_IsIE = true;   }
     //IE浏览器    if(global_IsIE)    {        xmlDoc = new ActiveXObject("Msxml2.DOMDocument");        xmlDoc.async = false;        xmlDoc.preserveWhiteSpace=true;         try        {               //xmlType是 指xml的类型0表示文件,1表示字符串组成的xml
             if(xmlType == 0)         {         xmlDoc.load(xmlFile);         }         if(xmlType == 1)         {         xmlDoc.loadXML(xmlFile);         }         return xmlDoc;        }        catch(e)        {         alert(xmlDoc.parseError.reason);         }    }
    然后用那个生成的xmlDoc对象,即
    maxNum=xmlDoc.getElementsByTagName("content").length;
    alert(maxNum);
    这样才是2