Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
XML parsing help
17/01/2014
19:31
Avatar
JimC
Member
Members
Forum Posts: 5
Member Since:
17/01/2014
sp_UserOfflineSmall Offline

Hello, I am new to using jqGrid and need help to get the XML data from my sharepoint to show up in jqGrid. I read through the documentation but there wasn't any examples for the XML data that I am faced with. This is the output from my sharepoint when I retrieve data with Javascript AJAX. 

<?xml version="1.0" encoding="utf-8"?>

  <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" mlns:xsd="http://www.w3.org/2001/XMLSchema">

<soap:Body>

<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">

<GetListItemsResult>   

<listitems xmlns:z='#RowsetSchema'><listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'>

<rs:data ItemCount="2">

<z:row Field1='16475' Field2='John Smith' Field3='Male'>

<z:row Field1='16456' Field2='Jane Doe' Field3='Female'>

</rs:data> </listitems></GetListItemsResult></GetListItemsResponse> </soap:Body></soap:Envelope>      

How do I code the jqGrid xmlReader to read this XML? Please help!

20/01/2014
16:00
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Parsing with namespaces is a little bit diffrent with jQuery.

I have never thest this, but you will need to add  double esc chars in the jsonReader

By example

...

jsonReader: {

...

root : "rs\\\\\:data",

...

}

Sorry for the changes the editor is buggy. I mean two '\' '\'.

More you can find here

Please let me know if this work for you.

Thank you.

Kind Regards

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.

21/01/2014
16:08
Avatar
JimC
Member
Members
Forum Posts: 5
Member Since:
17/01/2014
sp_UserOfflineSmall Offline

Hi Tony, I tried that and it didn't work. My code is :

  xmlReader: {root: "rs\\\\:data",

                      row: "z\\\\:row",

                      repeatitems: false,

                      id: "[ows_ID]"

                     },        

This doesn't parse the xml and shows 0 results. Any other tips for parsing the XML returned from a sharepoint? Thanks!

22/01/2014
16:31
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Sorry, but I think that that you have read the docs how to parse attributes in jqGrid. You will need to to use xmlmap and set it like this:

colModel :  [

{name:'Field1', xmlmap : '[Field1]', ...}.

...

]

This is the way that I think it is the best way  to publish full test case - this will save time.

Now here is the demo

Regards

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.

22/01/2014
18:02
Avatar
JimC
Member
Members
Forum Posts: 5
Member Since:
17/01/2014
sp_UserOfflineSmall Offline

This is the code I have. It still doesn't work to parse that XML. The xml.txt is just a file saved on the server with the XML code. I am at a lost as to what it missing…. I read through the documentation and it seems like this is the correct way to parse that XML. Do you know of any other sites where someone might be able to assist on this?

jQuery("#listXML").jqGrid({ 

      datatype: "xml",

      url: "http://www.mysite.net/XML.txt";,

      height: 250, 

      colNames: ['ID No', 'Country'], 

      colModel: [ {name: 'id', xmlmap:'[ows_ID]'}, 

  {name: 'country', xmlmap:'[ows_Country]'}

      ], 

      xmlReader: { root: "rs\:data", 

       row: "z\:row",

              repeatitems: false,

                 id: "[ows_ID]"

      },
       multiselect: true, 

       caption: "Test" 

    });

22/01/2014
19:48
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Please check if the xml file that you have is a VALID XML.

The very simple way to test is to read the same file using only jQuery and not jqGrid.

If you have succes with this, then I'm sure there will be no problems with jqGrid.

If you are lost on this, please zip the file and send it to my mail.

Kind 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.

22/01/2014
22:06
Avatar
JimC
Member
Members
Forum Posts: 5
Member Since:
17/01/2014
sp_UserOfflineSmall Offline

This is basically the XML here. You can copy/paste it into a text file. I can parse this with jQuery using this function.  I suppose if I can't get jqGrid to read the XML directly, I can parse the XML and save it into an array and then pass the array to jqGrid but I would much prefer to just have jqGrid directly read the XML. 

 $(data).find('z:row, row').each(function ()        {$("#ows_Country").val($(this).attr('ows_Country'));
 });

XML File:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soa.....038;hellip;..038;hellip;..&quot; xmlns:xsi="http://www.w3.org/2001/XMLSche.....038;hellip;..038;hellip;..&quot; xmlns:xsd="http://www.w3.org/2001/XMLSche.....038;hellip;..038;hellip;..msResponse xmlns="http://schemas.microsoft.com/s.....038;hellip;..038;hellip;..;listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'>

<rs:data ItemCount="1">

<z:row ows_ID='16475' ows_Country='Denmark' ows_Reporting_Month='2012-MAR' ows_SourceID='test parent 1' ows_Created='2013-04-10 13:29:03' ows_Cluster='null' ows_NewOrUpdatedRecord='0' ows_RecordUpdate='0' />

</rs:data>

</listitems></GetListItemsResult></GetListItemsResponse></soap:Body></soap:Envelope>

22/01/2014
22:12
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Zip the file and send it to my mail. Look at the example posted from me. It is quite similar.

Making copy/paste from this editor is not recommended.

Regards

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
21 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information