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>
相关文档:
<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 {
  ......
java代码
package com.xml.action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class XMLAction extends ActionSupport{
private static final long serialVersionUID = 1L;
private String username;
private String mobile;
public void setUs ......
// 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 ......
用arguments对象检测传递给函数的参数个数:arguments.length
function test(){
if(arguments.length == 1)
alert(arguments[0] + ",你好");
else if(arguments.length == 2)
alert(a ......