Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Nov 08, 2008 18:26
open dhtmlx forum
dhtmlxGrid:problem with xmlstring load

I am getting javascript error when loading from xml string. If I copy same xml in a file and call grid.loadXML("file.xml"), it woks fine.
How do I load grid from xml string?

Following gives javascript error
mygrid_62.parse("<?xml version="1.0" encoding="UTF-8"?>
1633<rows>
1634 <row id="62_0">

1635 <cell>identifier2</cell>
1636 <cell>multi choice label1,multi choice label2</cell>
1637 <cell>11/20/2008</cell>
1638 </row>
1639 <row id="62_1">
1640 <cell>identifier</cell>
1641 <cell>multi choice label1</cell>
1642 <cell>11/21/2008</cell>
1643 </row>
1644</rows>
1645");
Answer posted by Support on Nov 10, 2008 02:07
Beware, that used js string must not violate js script rules, in case above , it seems that data occupy few code lines, which break js string recognition. 
Use single line string, or place it inside some temporary container. 

<textarea id="xml_here"><?xml version="1.0" encoding="UTF-8"?>
1633<rows>
1634 <row id="62_0">

1635 <cell>identifier2</cell>
1636 <cell>multi choice label1,multi choice label2</cell>
1637 <cell>11/20/2008</cell>
1638 </row>
1639 <row id="62_1">
1640 <cell>identifier</cell>
1641 <cell>multi choice label1</cell>
1642 <cell>11/21/2008</cell>
1643 </row>
1644</rows>
</textarea>
...
mygrid_62.parse(document.getElementById("xml_here").value);