不用,写个xsl解析一下就是了,嘿嘿

解决方案 »

  1.   

    test.htm
    ------------------------------
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    </head>
    <body>
    <xml id="test">
    <NewDataSet>
      <table>
         <user_name>006</user_name>
         <other_name>张表</other_name>
         <id>6</id>
         <sex>男</sex>
      </table>
      <table>
         <user_name>008</user_name>
         <other_name>王有在</other_name>
         <id>6</id>
         <sex>男</sex>
       </table>
       <table>
         <user_name>009</user_name>
         <other_name>我们的祖国</other_name>
         <id>6</id>
         <sex>男</sex>
       </table>
    </NewDataSet>
    </xml>
    <script language="javascript">
    xml = document.getElementById("test").XMLDocument;
    xsl = new ActiveXObject( "Msxml2.DOMDocument");
    xsl.load( "test.xsl" );
    alert(xml.transformNode(xsl));
    </script>
    </body>
    </html>
    <script>
    </script>--------------------------test.xsl -----------------------------
    <?xml version="1.0" encoding="GB2312"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/NewDataSet">
    <xsl:for-each select="table">
    <div class="talkrighttop">
    <div class="talkrighttopxiao">
    <xsl:choose>
    <xsl:when test="sex='男'">
    男<IMG src="images/men.gif"/>
    </xsl:when>
    <xsl:otherwise>
    女<IMG src="images/women.gif"/>
    </xsl:otherwise>
    </xsl:choose>
    </div>
    <div class="talkrighttopbig">
    <xsl:value-of select="other_name"/>
    </div>
         </div>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
      

  2.   

    <div class="talkright" id="rightOnLine">
         <div class="talkrighttop">
    <div class="talkrighttopxiao"><IMG src="images/men.gif"></div>
    <div class="talkrighttopbig">张表</div>
         </div>
         <div class="talkrighttop">
    <div class="talkrighttopxiao"><IMG src="images/men.gif"></div>
    <div class="talkrighttopbig">王有在</div>
         </div>
         <div class="talkrighttop">
    <div class="talkrighttopxiao"><IMG src="images/women.gif"></div>
    <div class="talkrighttopbig">孙红</div>
         </div>
         <div class="talkrighttop">
    <div class="talkrighttopxiao"><IMG src="images/women.gif"></div>
    <div class="talkrighttopbig">李红</div>
         </div>            ......注:根据返回的数据行数来决定多少行,是动态的</div>
    <xml id=x>
    <NewDataSet>
      <table>
         <user_name>006</user_name>
         <other_name>张表</other_name>
         <id>6</id>
         <sex>男</sex>
      </table>
      <table>
         <user_name>008</user_name>
         <other_name>王有在</other_name>
         <id>6</id>
         <sex>男</sex>
       </table>
       <table>
         <user_name>009</user_name>
         <other_name>我们的祖国</other_name>
         <id>6</id>
         <sex>男</sex>
       </table>
    </NewDataSet>
    </xml>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var x=new ActiveXObject("Microsoft.XMLDOM")
    x.loadXML(document.all.x.innerHTML);  //这个XML数据你自己搞
    var node = x.selectSingleNode("/NewDataSet");
    var str = "";
    if(node.hasChildNodes())
    {
        for(var i=0; i<node.childNodes.length; i++)
        {
            var sex = node.childNodes[i].childNodes[3].text;
            var other_name = node.childNodes[i].childNodes[1].text;
            str += '<div class="talkrighttop">';
            str += '<div class="talkrighttopxiao"><IMG src="images/'+ (sex=="男"? "men" : "women") +'.gif"></div>';
        str += '<div class="talkrighttopbig">'+ other_name +'</div>';
            str += '</div>';
        }
    }
    document.getElementById("rightOnLine").innerHTML = str;
    //-->
    </SCRIPT>
      

  3.   

    firefox的xmldom和ms的很多地方不太一样我都是用foreach去寻找的,有没有firefox的编程手册的??比如.text在ff里用.textContent