【发布时间】:2014-06-14 06:20:20
【问题描述】:
我正在尝试使用 jqGrid 4.6 和 jquery 1.11 呈现我的 xml。我在使用命名空间读取属性时遇到问题。
下面是我的xml:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed>
<id>1234/</id>
<title type="text">ABCD</title>
<entry>
<id>1</id>
<title type="text">Entry 1</title>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:ContentTypeID>1</d:ContentTypeID>
<d:TitleOfItem />
<d:lastupdated>2014-04-22</d:lastupdated>
</m:properties>
</content>
</entry>
<entry>
<id>2</id>
<title type="text">Entry 2</title>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:ContentTypeID>2</d:ContentTypeID>
<d:TitleOfItem />
<d:lastupdated>2014-04-22</d:lastupdated>
</m:properties>
</content>
</entry>
</feed>
网格脚本:
<script type="text/javascript">
jQuery(document).ready(function(){
$("#grid")
.jqGrid({
url:'mytemplate.xml',
datatype: "xml",
xmlReader: {
root:"feed",
row:"entry",
repeatitems:false
},
colModel:[
{name:'id', index:'id', width:100, align:'center', xmlmap: "id"},
{name:'ContentTypeID', index:'invid', width:100, align:'center', xmlmap:"????"}
],
height:250,
rowNum:10,
rowList:[10,20,30],
viewrecords: true,
loadonce: true
});
});
</script>
如何从上述 xml 中读取 ContentTypeID? 我试过这个功能
xmlmap: function (obj) {
return $(obj).find(">content>RequestedDeliveryDetails").attr("ContentTypeID");
}
还有
xmlmap: "[nodeName=content.m:properties.d:ContentTypeID]" },
到目前为止没有运气。
提前致谢!
【问题讨论】:
-
您使用哪些网络浏览器以及哪个版本?
标签: javascript jquery xml jqgrid namespaces