Forum



12:05

14/06/2010

Hello,
I'm trying to consume a web service which return a namespaced xml (see example under):
<ns:getResults xmlns:ns="http://app.ws" xmlns:ax21="http://dto.app.ws/xsd">
<ns:return type="ws.ccmx.dto.ResultType">
<ax21:anaDept>INFO</ax21:anaDept>
<ax21:anaServ>0000</ax21:anaServ>
<ax21:categorieCode>01</ax21:categorieCode>
<ax21:categorieLib>CADRE</ax21:categorieLib>
<ax21:coefficient>150</ax21:coefficient>
<ax21:dtAnc>2010-03-08 00:00:00.0</ax21:dtAnc>
<ax21:dtEntreeEtab>2010-03-08 00:00:00.0</ax21:dtEntreeEtab>
<ax21:dtEntreeSoc>2010-03-08 00:00:00.0</ax21:dtEntreeSoc>
<ax21:dtSortieEtab xmlns:xsi="http://www.w3.org/2001/XMLSche.....a-instance" xsi:nil="true" />
<ax21:dtSortieSoc xmlns:xsi="http://www.w3.org/2001/XMLSche.....a-instance" xsi:nil="true" />
<ax21:emploiCode>COSS</ax21:emploiCode>
<ax21:emploiLib>Consultant senior</ax21:emploiLib>
<ax21:etabCode>150</ax21:etabCode>
<ax21:etabLib>CompanyName</ax21:etabLib>
<ax21:fonction>Ingenieur</ax21:fonction>
<ax21:matricule>101A51</ax21:matricule>
<ax21:nom>MANSOIF</ax21:nom>
<ax21:nomNaiss>Mansoif</ax21:nomNaiss>
<ax21:position>2.1</ax21:position>
<ax21:prenom>Gerard</ax21:prenom>
<ax21:socCode>101</ax21:socCode>
<ax21:socLib>Company</ax21:socLib>
<ax21:statut>Cadre</ax21:statut>
<ax21:typeRes>NORMAL</ax21:typeRes>
</ns:return>
</ns:getResults>
My question is: is it possible to use namespaced xml to load jqGrid, if yes what does the xmlReader option should look like?
Here is my actual code but i have try different things like ignoring namespaces or typing directly the namespace prefix without escaping the ':' caracter...
jQuery("#results").jqGrid({
url: '/Resources/Example2.xml',
datatype: "xml",
xmlReader: {
root: "ns\\:getResults",
row: "ns\\:return",
repeatitems: false
},
colNames: ['Nom', 'Prénom'],
colModel: [
{ name: 'lastName', index: 'lastName', width: 200, xmlmap: "ax21\\:nom" },
{ name: 'firstName', index: 'firstName', width: 300, xmlmap: "ax21\\:prenom" },
],
rowNum: 10,
autowidth: true,
rowList: [10, 20, 30],
pager: '#pager',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: "XML Example"
}); //.navGrid('#pager1', { edit: false, add: false, del: false });
When I modify the xml to remove all namespace, it works but i can't modify the web service. Should I need to parse the xml to remove all namespace before passing it to the jqGrid ?
14:34

Moderators
30/10/2007

Hello,
This is not a jqGrid problem, but rather jQuery.
Maybe you will need to look here:
http://stackoverflow.com/quest.....namespaces
http://thompson-web.blogspot.c.....paces.html
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
16:00

14/06/2010

Thanks Tony for your help, you lead me to the answer although it was a bit tricky (for me at least). Just a exemple if anyone else gets stuck :
If you want to load this kind of XML :
<ns:results xmlns:ns="http://app.ws" xmlns:ax21="http://dto.app.ws/xsd">
<ns:result>
<ax21:nom>JADEZ</ax21:nom>
<ax21:prenom>Bertrand</ax21:prenom>
</ns:result>
<ns:result>
<ax21:nom>LOPEZ</ax21:nom>
<ax21:prenom>Julien</ax21:prenom>
</ns:result>
<ns:result>
<ax21:nom>NORBERT</ax21:nom>
<ax21:prenom>Thomas</ax21:prenom>
</ns:result>
</ns:results>
Your jqGrid declaration should look like this:
jQuery("#results").jqGrid({
url: '/Resources/Example3.xml',
datatype: "xml",
xmlReader: {
root: "[nodeName=ns:results]",
row: "[nodeName=ns:result]",
repeatitems: false
},
colNames: ['Nom', 'Prénom'],
colModel: [
{ name: 'lastName', index: 'lastName', width: 200, xmlmap: "[nodeName=ax21:nom]" },
{ name: 'firstName', index: 'firstName', width: 300, xmlmap: "[nodeName=ax21:prenom]" },
],
rowNum: 10,
pager: '#pager',
viewrecords: true,
caption: "XML Example"
});
Thanks all and keep up the great work !!
Most Users Ever Online: 715
Currently Online:
46 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66