Results 1 to 5 of 5

Thread: parsing nested XML: xml reader

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    7
    Vote Rating
    2
      1  

    Default parsing nested XML: xml reader

    Hi
    I have an Xml response from server like,

    <properties>
    <property id=”123” name=”p1”>
    <value name=”v1” attrb1=”12” />
    <value name=”v3” attrb1=”12” />
    <value name=”v4” attrb1=”12” />
    </property>
    <property id=”13” name=”p2”>
    <value name=”v2” attrb1=”12” />
    </property>
    <properties>

    I understand that using 'hasMany' config I can store the xml data into two models (say, Property & Value),only if the value elements are inside a <values> </values> tag. For example,

    <property id=”123” name=”p1”>
    <values>
    <value name=”v1” attrb1=”12” />
    <value name=”v3” attrb1=”12” />
    <value name=”v4” attrb1=”12” />
    </values>
    </property>

    But, my server response doesn't have this <values> tag and I can't modify the server response. Is there any way I can read my server response using xml reader?? or can i parse my xml response somehow OR modify it on client side before reading ??

    Any help is appreciated... Thanks

  2. #2
    Sencha Premium User mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    693
    Vote Rating
    13
      -1  

    Default

    You can define a mapping from XML structure path to model field see:

    http://docs.sencha.com/touch/2-0/#!/...ld-cfg-mapping

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    7
    Vote Rating
    2
      1  

    Default

    Hi Thanks for replying.. But how can i map multiple records of that model to a specific record ? Could you specify an example.. Thanks again..

  4. #4
    Sencha Premium Member jordandev's Avatar
    Join Date
    Feb 2011
    Location
    BC, Canada
    Posts
    43
    Vote Rating
    4
      0  

    Default

    I am also wondering this.


    There doesn't seem to be anyway to get the hasMany association to get all of the <value> elements without having a <values> parent.


    Seems like an oversight in the XML reader to me.

  5. #5
    Sencha Premium User
    Join Date
    Jul 2009
    Posts
    78
    Vote Rating
    3
      0  

    Post Is this a xmlreader spec or bug?

    I have the same problem.

    So, if respons xml file format had the some bottom node with same name , I can't get the node value.
    If I set the bottom node to record config , I can't get the value.
    If I set the next bottom node to record config , I get the only one bottom node value.

    Is there the solution?

    Example: I can't get the LastNode value with xmlreader.

    <Node1>
    <Node2>
    <LastNode>1</LastNode>
    <LastNode>2</LastNode>
    <LastNode>3</LastNode>
    <LastNode>4</LastNode>
    <LastNode>5</LastNode>
    <LastNode>6</LastNode>
    <LastNode>7</LastNode>
    <LastNode>8</LastNode>
    </Node2>
    </Node1>

    Thank you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •