javascript解析返回的xml各式的字符串
<script>
var flags ;
if(window.XMLHttpRequest) {
XMLHttpReq = new XMLHttpRequest(); //firefox下执行此语句
}
else if(window.ActiveXObject) {
try{
XMLHttpReq = new ActiveXObject("Msxm12.XMLHTTP");
}catch(e){
try{
XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e) {}
}
}
XMLHttpReq.open("post","getDate.jsp",false);
XMLHttpReq.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded;charset=UTF-8");
XMLHttpReq.onreadystatechange = function () {
var statePending = XMLHttpReq.readyState;
if (statePending == 4&& XMLHttpReq.status==200)
{
if(window.ActiveXObject){
xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async = false;
xmlDoc.loadXML(XMLHttpReq.responseText.replace(/(^\s*)/g, ""));
} else if (document.implementation&&document.implementation.createDocument){
XMLHttpReq.open("GET",XMLHttpReq.responseText.replace(/(^\s*)/g, ""),false);
XMLHttpReq.send(null);
xmlDoc = XMLHttpReq.responseXML;
//return new XMLSerializer().serializeToString(xmlDoc);
}
flags = xmlDoc.getElementsByTagName("content");
}
}
XMLHttpReq.send(null);
for(var i =0;i<flags.length;i++)
{
var content = flags[i]; //得一个content结
相关文档:
C#序列化xml
关键步骤:
XmlSerializer xSerializer = new XmlSerializer(typeof(MyObj));
StringWriter sWriter = new StringWriter(CultureInfo.InvariantCulture);
XmlTextWriter xTextWriter = new XmlTextWriter(sWriter);
......
<!-- xml格式
<foo xmlns="test">
<bar attr='a'></bar>
<bar attr='b'></bar>
<bar attr='c'></bar>
</foo>
-->
<?php
$dom = new DOMDocument();
if (!$dom->load('attr.xml'))
{
echo "load books.xml failed!<br>";
re ......
<!-- xml 格式
<books>
<book id='1001'>
<author>andylin</author>
<title>c language</title>
<publisher id="aaa">O'Reilly</publisher>
</book>
<book id='1002'>
<author>congfeng</author>
<t ......
Flex 与 JavaScript 交互,主要依靠Flex的ExternalInterface,其提供了addCallBack和call方法.
下面的例子将演示Flex调用javascript,和javascript调用Flex。
js 代码
-------------------------------------------------------------------------------------------------------------
function hello(param) {
......
这里考虑的是.net服务器控件checkbox或checkboxList;
假设页面如下,chkDepart是部门,chkPeople是所属部门的人员
<div style="text-align: center" mce_style="text-align: center" width="95%" class="tab">
<asp:DataList ID="DataList1" ......