Reputation: 726
Can I access local XML files as data in jqGrid?
Upvotes: 2
Views: 6255
Reputation: 71
I could run a local example using xmlstring method after modify the example code that I saw in: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#xml_string
My modified code is:
var mystr =
"<?xml version='1.0' encoding='utf-8'?>"+
"<invoices>"+
"<rows>"+
"<row>"+
"<cell>data1</cell>"+
"<cell>data2</cell>"+
"<cell>data3</cell>"+
"<cell>data4</cell>"+
"<cell>data5</cell>"+
"<cell>data6</cell>"+
"</row>"+
"</rows>"+
"</invoices>";
Instead of:
var mystr =
"<?xml version='1.0' encoding='utf-8'?>
<invoices>
<rows>
<row>
<cell>data1</cell>
<cell>data2</cell>
<cell>data3</cell>
<cell>data4</cell>
<cell>data5</cell>
<cell>data6</cell>
</row>
</rows>
</invoices>";
Upvotes: 1
Reputation: 221997
You can load the contents of the XML file in a string variable and use datatype: 'xmlstring'
(see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#xml_string). It will work.
Upvotes: 4
Reputation: 1303
You want to access an XML file stored on the client's machine via JavaScript? I don't think that can be done.
The more common scenario is pulling your XML via an Ajax call. I'd also look at the "local" option on the jqGrid wiki. You could embed your data as JSON/XML in the HTML page and read it in when setting up your jqGrid.
Upvotes: 0