4 Replies Latest reply on Jul 7, 2009 8:48 AM by leybniz

    DataGrid and XML

    ianben Level 1

      Can anyone spot a problem with the following code:

       

      <mx:Model id="readingData" source="reading.xml"/>
          <mx:ArrayCollection id="readingAC" source="{readingData.row}"/>

       

      <mx:DataGrid id="readingGrid" dataProvider="{readingAC}" x="10" y="40" rowCount="4" width="675" color="#000000">
          <mx:columns>
          <mx:DataGridColumn dataField="title" headerText="Title" width="200"/>
          <mx:DataGridColumn dataField="author" headerText="Author" width="200"/>
          <mx:DataGridColumn dataField="isbn" headerText="ISBN" width="200"/>
          </mx:columns>
                 
      </mx:DataGrid>

       

      The error message I get is:


      Problem parsing external XML: C:\Documents and Settings\Ian\My Documents\RIA\src\reading.xml - (line 41) The entity name must immediately follow the '&' in the entity reference.    RIA_Prototype/src    Prototype.mxml  

       

      I have another DataGrid in the app. which works just fine but this one won't - and I don't understand the error message.

       

      Ian

        • 1. Re: DataGrid and XML
          leybniz Level 4

          post your reading.xml here, it seems it's not well formatted XML data in there.

          • 2. Re: DataGrid and XML
            ianben Level 1

            Hi Alexander the xml file:

             

            <?xml version="1.0"?>
            <reading>
                <row>
                    <contactid>1</contactid>
                    <title>My Sisters Keeper</title>
                    <author>Jodi Picoult</author>
                    <isbn>978-1-439-15726-8</isbn>
                </row>
                <row>
                    <contactid>2</contactid>
                    <title>Fearless Fourteen</title>
                    <author>Janet Evanovich</author>
                    <isbn>978-0-312-34952-3</isbn>
                </row>
                <row>
                    <contactid>3</contactid>
                    <title>Dead Until Dark</title>
                    <author>Charlaine Harris</author>
                    <isbn>9780441016990</isbn>
                </row>
                <row>
                    <contactid>4</contactid>
                    <title>From Dead to Worse</title>
                    <author>Charlaine Harris</author>
                    <isbn>978-0-441-01701-0</isbn>
                </row>
                <row>
                    <contactid>5</contactid>
                    <title>Wed Him Before You Bed Him</title>
                    <author>Sabrina Jeffries</author>
                    <isbn>978-1-416-56082-1</isbn>
                    </row>
                <row>
                    <contactid>6</contactid>
                    <title>Sail</title>
                    <author>James Patterson</author>
                    <isbn>9780446536103</isbn>
                </row>
                <row>
                    <contactid>7</contactid>
                    <title>The Last Oracle</title>
                    <author>James Rollins</author>
                    <isbn>978-0-06-123095-0</isbn>
                </row>
                <row>
                    <contactid>8</contactid>
                    <title>Angels & Demons</title>
                    <author>Dan Brown</author>
                    <isbn>9781416524878</isbn>
                </row>
                <row>
                    <contactid>9</contactid>
                    <title>Sundays at Tiffany’s</title>
                    <author>James Patterson</author>
                    <isbn>978-0-446-53631-8</isbn>
                </row>
                <row>
                    <contactid>10</contactid>
                    <title>Living Dead in Dallas</title>
                    <author>Charlaine Harris</author>
                    <isbn>978-0-441-01824-6</isbn>
                </row>
                <row>
                    <contactid>11</contactid>
                    <title>The Last Patriot</title>
                    <author>Brad Thor</author>
                    <isbn>978-1-416-54384-8</isbn>
                </row>
                <row>
                    <contactid>12</contactid>
                    <title>Rogue</title>
                    <author>Danielle Steel</author>
                    <isbn>978-0-440-24329-8</isbn>
                </row>
                <row>
                    <contactid>13</contactid>
                    <title>Club Dead</title>
                    <author>Charlaine Harris</author>
                    <isbn>9780441010516</isbn>
                </row>
                <row>
                    <contactid>14</contactid>
                    <title>Dead to the World</title>
                    <author>Charlaine Harris</author>
                    <isbn>978-0-441-01218-3</isbn>
                </row>

             

            </reading>

            • 3. Re: DataGrid and XML
              leybniz Level 4

              yep that's it! your xml file is not well formed

               

              <contactid>8</contactid>
              <title>Angels & Demons</title>

               

              you have ampersand symbol there, which is a violation resulted in your error above.

              I can tell you the easiest way how to ensure wether your xml file valid or not,

              save xml text to Notepad save as *.xml extension and open this file using Internet Explorer

              replace & by &amp; and you are done

               

              If you feel this message answers your question or helps, please mark it respectively

              • 4. Re: DataGrid and XML
                ianben Level 1

                Thanks a lot Alex - so simple if you know what you are looking for and thanks for the quick reply and tip about checking xml.

                Ian