使用javascript从Infopath xml文件中读取数据 [英] Read data from Infopath xml files using javascript

查看:61
本文介绍了使用javascript从Infopath xml文件中读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Techies,

Hello Techies,

最近,我们使用metalogix将大量的Infopath数据从遗留应用程序迁移到SharePoint 2013 Standard版本。通过我们没有使用infopath应用程序,但我们希望将它们作为参考目的。

Recently, we have migrated huge chunk of Infopath data from legacy applications to SharePoint 2013 Standard version using metalogix. Through we are not using infopath applications but we wanted to have them as reference purpose.

有些表单可以很好地发布数据连接更改,并且有一些表单是基于浏览器的infopath表格。

There were some forms which worked fine post data connection changes and there are chunks of forms which are browser based infopath forms.

所以我尝试使用Rest Api方法读取xml数据,我能够在浏览器控制台中查看数据。

So I tried to read the xml data using Rest Api approach and i was able to go through the data in browser console.

现在我想读取节点值并将它们绑定到html标签。

Now I want to read the node values and bind them to html tags.

这是我的js代码:

(function(){
    $.ajax({
        type:'GET',
        url: 'http://sp/siteCollection/_layouts/15/FormServer.aspx?XmlLocation=/Sitename/ReviewForm_271.xml?NoRedirect=true',
        datatype: 'xml',
        cache: false,
        contentType: "text/xml; charset=\"utf-8\"",
        success:function(xmlContent){
            console.log(xmlContent);
           displayData(xmlContent);
        },
        error:function(){
            console.log('failed');
        }
    });
});


function displayData(xmldata)
{
	//var x = xmldata.getElementsByTagName("FileUrl");//[0].childNodes[0];
	var xmlDoc = $.parseXML(xmldata); // In debugger I have the xml here. 
	var $xml = $(xmlDoc);
		var Facility = $xml.find('my\\:Form').find('my\\:PortalForm').text();
	//$("#Facility").append('Facility =' + Facility );	
	alert(Facility);
	
}

这是来自浏览器控制台的数据:

And here is the data from browser console:

我会从突出显示的节点读取数据将它们绑定到html标签。任何人都可以帮我解决这个问题。

I would to read the data from highlighted node and bind them to html tags. Can anyone help me how to proceed with this.

推荐答案

您好,

以下代码供您参考,将代码添加到Web部件页面的脚本编辑器Web部件中。

The following code for your reference, add the code into script editor web part in the web part page.

<script type="text/javascript" src="//code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">


(function(){
(function(){


.ajax({
类型:'GET',
url:'http://sp/siteCollection/_layouts/15/FormServer.aspx?XmlLocation = / Sitename / ReviewForm_271.xml?NoRedirect = true',
datatype :'xml',
cache:false,
contentType:" text / xml; charset = \" utf-8 \"",
complete:function(xmlContent ){
displayData(xmlContent);
},
错误:function(){
console.log('failed');
}
} );
});


函数displayData(xmldata){
var xml = xmldata.responseText;
var xmlDoc =
.ajax({ type:'GET', url: 'http://sp/siteCollection/_layouts/15/FormServer.aspx?XmlLocation=/Sitename/ReviewForm_271.xml?NoRedirect=true', datatype: 'xml', cache: false, contentType: "text/xml; charset=\"utf-8\"", complete:function(xmlContent){ displayData(xmlContent); }, error:function(){ console.log('failed'); } }); }); function displayData(xmldata){ var xml=xmldata.responseText; var xmlDoc =


这篇关于使用javascript从Infopath xml文件中读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆