[ 2 posts ]

Prateek

  • Offline
  • Profile

Not able to fetch all values using useXPath

Post Posted: Sun Dec 12, 2010 3:04 am
+0-
Hi Friends,

I want to fetch value from the xml below
++++++++++++++++
<ims-event>
<topic>Abc</topic>
<subtopic>details</subtopic>
<params>
<var name="id">001</var>
<var name="name">Vikas</var>
<var name="date">10/10/2010</var>
<var name="intime">10:10</var>
</params>
<params>
<var name="id">002</var>
<var name="name">Prateek</var>
<var name="date">10/10/2010</var>
<var name="intime">10:20</var>
</params>
<params>
<var name="id">003</var>
<var name="name">Abhishek</var>
<var name="date">10/10/2010</var>
<var name="intime">10:30</var>
</params>
</ims-event>
+++++++++++++++++++++++++++

JavaScript for retrieving data from xml above is
+++++++++++++++++++++++++++++++++++++++++++++++
YAHOO.example.XPath = function() {
var myColumnDefs = [
{key:"var",label:"Id"},
{key:"var",label:"Name"},
{key:"var",label:"Date"},
{key:"var",label:"In Time"}

];

var myDataSource = new YAHOO.util.DataSource("/DataSource/datasource-versum-format.xml");
myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
myDataSource.useXPath = true;
myDataSource.responseSchema = {
metaFields: {rootatt:"/ims-event"},
resultNode: "params",
fields: [ {key:"var", locator:"var"}, {key:"var", locator:"var"}, {key:"var", locator:"var"}, {key:"var", locator:"var"} ]
};

var myDataTable = new YAHOO.widget.DataTable("xpath", myColumnDefs, myDataSource);

return {
oDS: myDataSource,
oDT: myDataTable
};
}();
++++++++++++++++++++++++++++

Instead of getting all the entries from xml, I am getting only last entry in all Table fields. :(
Please find the snapshot of result.
http://2.bp.blogspot.com/_Cu0XC3dk-44/T ... /Xpath.png

Can anyone help me out how can I get all the details populated in Table from XML above.

Prateek

  • Offline
  • Profile

Re: Not able to fetch all values using useXPath

Post Posted: Thu Dec 16, 2010 6:40 am
+0-
Friends I wrote a javascript which returns value in form of xml, as below.
++++++++++++++++++++++++++
<ROWSET>
<ROW><ID>001</ID><NAME>Vikas</NAME><DATE>10/10/2010</DATE><TIME>10:10</TIME></ROW>
<ROW><ID>002</ID><NAME>Prateek</NAME><DATE>10/10/2010</DATE><TIME>10:20</TIME></ROW>
<ROW><ID>003</ID><NAME>Abhishek</NAME><DATE>10/10/2010</DATE><TIME>10:30</TIME></ROW>
</ROWSET>
+++++++++++++++++++++
Can anybody help me out is it possible to pass the above returned value in DataSource so that I can use it to create DataTable.

If not please do suggest the alternative solution.
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum