Domino后台代理和前台Web页面交换、处理XML过程(jquery方式)

    技术2022-05-19  31

    Part1:后台------------------〉前台

    后台:通过Agent组装成XML格式。然后用Print网前台发送,但是前面一定要先print一段头(content-type:Text/xml)定义为XML。

    Print |content-type:Text/xml| Print |XML内容Here...|

    XML例子如下:

    <?xml version='1.0' encoding='ISO-8859-1'?> <bookstore> <book category='children'> <title lang='en'>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category='cooking'> <title lang='en'>Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category='web' cover='paperback'> <title lang='en'>Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> <book category='web'> <title lang='en'>XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book> </bookstore>

     

    前台获得XML的格式如下:

        注意     dataType: 'xml'————获取内容格式                type: 'GET', —————获得内容

    $.ajax({ url: strURL+"agent?openagent", dataType: 'xml', type: 'GET', timeout: 10000, error: function(xml){ alert("loading xml error"); }, success: function(xml){ $(xml).find("book").each(function(i){ var book = $(this) alert("title:"+book.children("title").text()) alert("book's attribute: category=" + book.attr("category")) }) } });

     

     


     

    Part2:前台------------------〉后台

    前台通过组合XML方式通过JS提交,代码如下

    注意两点,dataType:"xml"(提交格式) 和 type:"post"(向服务器发送数据)

    var varData = getXML() $.ajax({ url:strURL, dataType:"xml", type:"post", data:varData, success:function(xml){ alert(xml); } });

     

    后台,通过doc.REQUEST_CONTENT(0)获得XML。解析过程:见我的另外一篇博文:Notes中LS处理XML情况

     


    最新回复(0)