How to get selected data from input xml file.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to get selected data from input xml file.

Kiran Kumar
Hello,

my input file is like : <data>
        <po>
                <value>AA</value>
                <des>12</des>
        </po>
        <po>
                <value>BB</value>
                <des>56</des>
        </po>
        <po>
                <value>CC</value>
                <des>88</des>
        </po>
</darta>

Now how can i get only selected record in to form (which po value is BB), using Xforms only.

Here i want to view only one record which is having value is BB.

Is there any possible way to filter the data in xforms.

Please help me.

Thank you,
kiran.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to get selected data from input xml file.

Alessandro  Vernet
Administrator
Hi Kiran,

You're not saying in which context you need this, but getting the `des` where `value = BB` is typically done in XPath, and can be done with `/data/po[value = 'BB']/des`. Does this help?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to get selected data from input xml file.

Kiran Kumar

Thank you Alessandro Vernet it is working for me.

as you said : /data/po[value = 'BB']/des

i have another issue to solve my input file is like below.

</data>
        <po>
                <value>AA</value>
                <name>qw</name>
                <des index="1">12</des>

        </po>
        <po>
                <value>BB</value>
                <name>sdf</name>
                <des index="1">52</des>
                <des index="2">561</des>

        </po>
        <po>
                <value>CC</value>
                <name>aw</name>
                <des index="1">45</des>
                <des index="2">36</des>
                <des index="3">126</des>

        </po>
</data>


Here i am able to get  name tag data if value =CC ,how can get des data using index,

                                      <xf:input
                                                ref="instance('data-instance')/data/po[value = 'CC']/des????">
                                                <xf:label>Desc 1:</xf:label>
                                        </xf:input>
                                        <xf:input
                                                ref="instance('data-instance')/data/po[value = 'CC']/des????">
                                                <xf:label>Desc 2:</xf:label>
                                        </xf:input>
                                        <xf:input
                                                ref="instance('data-instance')/data/po[value = 'CC']/des????">
                                                <xf:label>Desc 3:</xf:label>
                                        </xf:input>

please help me.


Thanks,
kiran
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to get selected data from input xml file.

Alessandro  Vernet
Administrator
Hi Kirian,

You can use `instance('data-instance')/data/po[value = 'CC']/des[1]` (and `des[2]`… and so on). This means “take the nth `des`”. In you could also want to say “take the `des` such as `index = 1`, which would be `des[@index = '1']”. I hope this works for you,

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to get selected data from input xml file.

Kiran Kumar


Thank you Alessandro Vernet, it is working.





Thanks,
kiran.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to get selected data from input xml file.

Alessandro  Vernet
Administrator
Excellent Kiran, and thank you for the confirmation.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Loading...