Categories | Question details Back To List | ||||||||
Invalid XML I am evaluating your product and cannot get my first grid to work. Javascript is: mygrid = new dhtmlXGridObject('gridbox'); alert('Running Script'); mygrid.imgURL = "images/"; mygrid.setHeader("Property,C1_C4,#cspan,C5S,#cspan"); mygrid.attachHeader("#rspan,Input,Calc.,Input,Calc."); mygrid.setInitWidths("200,100,100,100,100"); mygrid.setColAlign("left,right,right,right,right"); mygrid.setColTypes("ro,ro,ro,ro,ro"); mygrid.setColSorting("str,int,int,int,int"); mygrid.init(); mygrid.loadXML("griddata/grid.xml"); and the XML is: <?xml version="1.0" encoding="iso-8859-1"?> <rows> <row id="1"> <cell>Cut Type</cell> <cell>Contiguous</cell> <cell>Contiguous</cell> <cell>Contiguous</cell> <cell>Contiguous</cell> </row> <row id="2"> <cell>Cut Status</cell> <cell>Ready</cell> <cell>Ready</cell> <cell>Ready</cell> <cell>Ready</cell> </row> <row id="3"> <cell>Percent weight yield</cell> <cell>1.15</cell> <cell>1.14996093971</cell> <cell>1.09</cell> <cell>1.08996297764</cell> </row> <row id="4"> <cell>Component composition by weight_Methane</cell> <cell>0.01</cell> <cell>0.862068965517</cell> <cell> </cell> <cell> </cell> </row> <row id="5"> <cell>Component composition by weight_Ethane</cell> <cell>0.02</cell> <cell>1.72413793103</cell> <cell> </cell> <cell> </cell> </row> <row id="6"> <cell>Component composition by weight_Propane</cell> <cell>0.23</cell> <cell>19.8275862069</cell> <cell> </cell> <cell> </cell> </row> <row id="7"> <cell>Component composition by weight_Iso butane</cell> <cell>0.19</cell> <cell>16.3793103448</cell> <cell> </cell> <cell> </cell> </row> <row id="8"> <cell>Component composition by weight_N butane</cell> <cell>0.71</cell> <cell>61.2068965517</cell> <cell> </cell> <cell> </cell> </row> <row id="9"> <cell>Component composition by weight_N pentane</cell> <cell> </cell> <cell> </cell> <cell>1.09</cell> <cell>100</cell> </row> </rows> On the screen I see the column headings and then the message I get is "Invalid XML" and the table contents don't display. Any ideas? Answer posted on Nov 14, 2007 05:24 Please check attached sample - it uses code and XML from you snippet and it works fine "Invalid XML" message means that your XML can't be correctly parsed - are you loading it from static XML file or from server side script. In second case script must set correct content - type ( text/xml ) and no whitespaces before <?xml tag. Also if you loading data from local filesystem ( not http:// but C:/some... ) there is a limitation for IE , in such mode it able to parse only UTF-8 based XML ( if page loaded by http:// any encoding can be used ) Attachments (1)
Answer posted by DaveSawers on Nov 14, 2007 05:40 I discovered that the error was that I was using ampersand nbsp; in a cell instead of leaving it blank or just putting in a space. When posing the question here, your system changed the codes into a space which is why it worked for you. Thanks for your prompt reply though. Answer posted on Nov 14, 2007 07:32 If you need to use & in cell value you can do in one of two next way quoting <cell>&nbsp;</cell> escaping by cdata <cell><![CDATA[ ]]></cell> |