javascript加载xml文件
<mce:script language="javascript" type="text/javascript"><!--
//需要读取的xml文件
var uRl = "jsReadXml.xml";
var xmlDoc;
//初始化,给上述定义变量赋值
// function showcurcity(){
if(window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false"
xmlDoc.load(uRl);
getvalue();
}
else if(document.implementation && document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("", "root", null);
xmlDoc.load(uRl);
xmlDoc.onload=getvalueff;
}
// else {
// return null;
// }
// }
function getvalue()
{
var nodes=xmlDoc.documentElement.childNodes;
var now=new Date();
for(i=0;i<nodes.length;i++){
var value=nodes.item(i).childNodes.item(0).text ;
alert(nodes.item(i).childNodes.item(1).text);
alert(nodes.item(i).childNodes.item(2).text);
}
}
function getvalueff(){
var cCode=xmlDoc.getElementsByTagName("date");
var now = new Date();
var nowvalue=now.getFullYear()+'年'+(now.getMonth()+1)+'月'+now.getDate()+'日';
for(i=0;i<cCode.length;i++)
{
alert(xmlDoc.getElementsByTagName("imgsrc")[i].childNodes[0].nodeValue);
alert(xmlDoc.getElementsByTagName("title")[i].childNodes[0].nodeValue);
alert(xmlDoc.getElementsByTagName("url")[i].childNodes[0].nodeValue);
}
}
// --></mce:script>
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>滚动新闻类</title>
<style type="text/css">
body {
  ......
在面向对象编程语言中,对于this关键字我们是非常熟悉的。比如C++、C#和Java等都提供了这个关 键字,虽然在开始学习的时候觉得比较难,但只要理解了,用起来是非常方便和意义确定的。JavaScript也提供了这个this关键字,不过用起来就比 经典OO语言中要"混乱"的多了。
下面就来看看,在JavaScript中各种 ......
// TestXml.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include "tinyxml.h"
#include "lang.h"
#include <string>
using namespace std;
using namespace std;
#pragma comment(lib, "tinyxmld.lib")
B ......