javascript读取xml实现应用程序菜单效果
/*样式*/
<style type="text/css">
td{font-size:12px;}
.item{text-decoration:none;width:100%;height:100%; line-height:22px;cursor:default;color:Black;vertical-align:middle}
.staticTab{cursor:default;height:22px}
.staticTD{width:70px;text-align:center; vertical-align:middle;white-space:nowrap}
.dynamicTR{height:22px; vertical-align:middle}
.dynamicTab{width:60px;cursor:default;background-color:#ccebff;position:absolute;z-index:1}
.dynamicTDRight{text-align:right;font-size:9px;}
.dynamicTDCenter{text-align:left;white-space:nowrap}
</style>
/*--------------菜单应用到的js--------------------*/
var menuHTML="";
function createXMLHttpRequest(){xmlHttp=(window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();}
function getMenuData(){//从后太获取头部的单据或审批人等的信息
createXMLHttpRequest();
xmlHttp.open("GET","Menu.ashx?id="+(new Date()).getTime(),true);
xmlHttp.onreadystatechange=getMenu_onreadystatechange;//用函数名,不加括号.
xmlHttp.send(null);
}
function getMenu_onreadystatechange(){//相应处理
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
var menuXML=xmlHttp.responseXML.getElementsByTagName("menu");//childNodes
createStaticMenu(menuXML[0]);
}else
alert('服务器端发生错误!');
}
}
function getId(number,fatherId){
number+=1;
if(number<1
相关文档:
调用JavaScript文件
用作导航栏
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ......
通常在操作xml的时候,都是通过inputstream(很多情况下是FileInputStream)来读入xml并转为dom的,很多人会遇到这种情况数据不是从文件读入的而是从String中取得的
于是会使用
InputStream in = new ByteArrayInputStream (str.getBytes());来取得inputstream ,但是这种InputStream中数据被转成了byte数组,所以转dom ......
号称xmlhelper的一个类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
namespace WebApplication2
{
/// <summary>
/// XMLHelper XML文档操作管理器
/// </summary>
public class XMLHelper
{
public X ......
Procedure TForm1.Button1Click(Sender: TObject);
Var
xmlstr,FileName: String;
f: Textfile;
Begin
xmlStr := '<?xml version="1.0" encoding="gb2312"?>';
xmlstr := xmlstr + '<user><name>张三</name><sex>男</sex></user>';
sh ......