1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    9
    Vote Rating
    0
    bzborow1 is on a distinguished road

      0  

    Default XmlReader for Xml with multiple similar child nodes...

    XmlReader for Xml with multiple similar child nodes...


    Hi guys,

    I'm building a simple extjs reader that connects to a j2EE web service and displays the results. My problem is I don't know how I can map the XmlReader where there are multiple child node instances. Example xml:

    Code:
    - <result>
       - <attributes>
         <attribute>Geometry type: 4</attribute> 
    
        <attribute>Exterior ring: 1</attribute> 
    
        <attribute>Point count: 5</attribute> 
    
        <attribute>Lambert_Conformal_Conic</attribute> 
    
        <attribute>85758</attribute> 
    
        <attribute>993f75ed-dfc0-4d84-8d95-29462313f331</attribute>  
    
        <attribute>morrisonb</attribute> 
    
        <attribute>Thu May 27 00:00:00 CST 2010</attribute> 
    
        <attribute>4</attribute> 
    
       </attributes>
    
    
      - <extent>
         <minx>-480848.0771999992430210113525390625</minx>  
    
        <maxx>-479586.4708000011742115020751953125</maxx>  
    
        <miny>231779.4936999976634979248046875</miny> 
    
        <maxy>233042.39090000092983245849609375</maxy> 
    
       </extent>
    
    
       </result>
    And the javascript

    Code:
    Ext.onReady(function() {
        
        //Create the data store.
        var store = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                method: 'GET',
                disableCaching:true,
                url:"http://localhost:8085/agmafWSCplSearch/rest/attributeSearch?attr=township&attrv=16&attr=range&attrv=14&attr=meridian&attrv=w1&attr=section&attrv=10"
            }),
            reader: new Ext.data.XmlReader({
                record: 'result'
            },[
               {name: 'SR', mapping: 'attributes > attribute[1]'},
               {name: 'MinX', mapping: 'extent > minx'},
               {name: 'MinY', mapping: 'extent > miny'},
               {name: 'MaxX', mapping: 'extent > maxx'},
               {name: 'MaxY', mapping: 'extent > maxy'}
            ])
        });
        
        //Create the grid.
        var grid = new Ext.grid.GridPanel({
            store: store,
            columns: [
                      {header: "Spatial Reference", width: 240, dataIndex: 'SR', sortable: false},
                      {header: "Min-X", width: 120, dataIndex: 'MinX', sortable: false},
                      {header: "Min-Y", width: 120, dataIndex: 'MinY', sortable: false},
                      {header: "Max-X", width: 120, dataIndex: 'MaxX', sortable: false},
                      {header: "Max-Y", width: 120, dataIndex: 'MaxY', sortable: false}
            ],
            renderTo: 'example-grid',
            width: 720,
            height: 400
        });
    
        store.load();
    });
    What I'd like to do is dispay each attributes/attribute tag in a different column. How does the xpath work?

  2. #2
    Sencha User BitPoet's Avatar
    Join Date
    Sep 2008
    Location
    Bavaria
    Posts
    277
    Vote Rating
    1
    BitPoet is on a distinguished road

      0  

    Default


    As an XmlReader is supposed to consume more than one record, those records must be contained in the root node, not be the root node itself. So your result tags need to be wrapped inside a "document" tag, like
    HTML Code:
    <data>
      <result>
        <attributes>...</attributes>
        <extent>...</extent>
      </result>
    </data>
    Then, positionally accessing one of a number of identically named attributes can be done via the :nth syntax as stated in the DomQuery docs.
    Code:
    {name: 'SR', mapping: 'attributes > attribute:nth(1)'}

Similar Threads

  1. Multiple XML child nodes and XMLReader
    By binaryfever in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 9 Jun 2010, 2:39 PM
  2. xml grid - mapping child nodes with the same name
    By mbjorge in forum Ext 3.x: Help & Discussion
    Replies: 8
    Last Post: 22 Feb 2010, 2:54 AM
  3. Extend XML Tree Loader - Child nodes
    By yankee_gal in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 26 Mar 2009, 4:51 AM
  4. Ext.data.Record mapping on multiple xml-nodes
    By omdb in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 5 Aug 2007, 8:51 AM
  5. Ext.data.XmlReader :: Loading in unknown XML nodes.
    By MarkB in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 30 Mar 2007, 3:20 PM

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar