日期:2014-05-16  浏览次数:20399 次

javascript基础问题,谢谢回答!
程序如下:
<script   language= "javascript ">
var   rep= " <literature> <title> 标题 </title> <content> 内容 </content> </literature> ";
var   title=rep.getElementsByTagName( "title ").innerHTML;
var   content=rep.getElementsByTagName( "content ").innerHTML;
alert(a);
</script>


我只想取出标题和内容,不知道怎么解决,谢谢各位达人指教.



------解决方案--------------------
<script language= "javascript ">
var rep= " <literature> <title> 标题 </title> <content> 内容 </content> </literature> ";
var doc=new ActiveXObject( "Microsoft.XMLDOM ");

doc.async= "false ";

doc.loadXML(rep);
var x=doc.documentElement;

document.write(x.childNodes[0].childNodes[0].nodeValue);

document.write( " <br /> ");

document.write(x.childNodes[1].childNodes[0].nodeValue);

</script>