1
我想要一个javascript代码来远程调用alfresco的web脚本(http://10.0.2.2:8080/alfresco/service/api/login?u=admin & pw = admin) Android应用程序使用Phonegap并删除返回结果并将此返回结果附加到其他外部web脚本(http:// localhost:8080/alfresco/service/sample/folder/Company%20Home?format = atom)的调用。 请帮助我。解析xml文档的Javascript代码
我有这个示例代码,我怎么能改变它到我的需要...我想调用http://10.0.2.2:8080/alfresco/service/api/login?u=admin&pw=admin解析返回值,并将它附加到webscript http://localhost:8080/alfresco/service/sample/folder/Company%20Home?format=atom的一个更多的调用。
<html>
<head>
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script src="jquery-1.4.2.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
function bodyload(){
alert("We are calling jquery's ajax function and on success callback xml parsing are done");
$.ajax({url:'http://www.edumobile.org/blog/uploads/XML-parsing-data/Data.xml',
url:'
dataType:'application/xml',
timeout:10000,
type:'POST',
success:function(data) {
console.log("Customers Tab",data);
$("#bookInFo").html("");
$("#bookInFo").append("<hr>");
$(data).find("Book").each(function() {
$("#bookInFo").append("<br> Name: " + $(this).find("name").text());
$("#bookInFo").append("<br> Address: " + $(this).find("address").text());
$("#bookInFo").append("<br> Country: " + $(this).find("country").text());
$("#bookInFo").append("<br><hr>");
});
},
error:function(XMLHttpRequest,textStatus, errorThrown) {
alert("Error status :"+textStatus);
alert("Error type :"+errorThrown);
alert("Error message :"+XMLHttpRequest.responseXML);
$("#bookInFo").append(XMLHttpRequest.responseXML);
}
});
}
</script>
</head>
<body onload="bodyload()">
<button onclick="bodyload()">Get Ticket</button>
<p id="bookInFo"></p>
</body>
我还没有明确的想法关于Javascript,因为我探讨了在android u中解析xml唱手机通过调用Ajax调用和jquery完成(http://www.kumarchetan.com/blog/2012/01/14/my-first-android-app-or-how-to-develop-an-android-app -using-phonegap-and-jquery /)。我无法将它与我的需求联系起来......已经厌倦了看到上面的示例示例... – Surya 2012-02-29 04:09:35
您可以使用E4x在javascript中进行xml解析:http:// www .w3schools.com/xml/xml_e4x.asp – 2012-02-29 07:05:03
@MatjazMuhic这是否支持使用Phonegap的android应用程序? – Surya 2012-02-29 07:10:05