-
How to show data island records through javascript
Hi,
I am trying to show all the data from xml thru javascript for loop. But I
am getting always the absolute record data for all the rows. Please see the
fllowing code.
Please help me.
********************************* CODE ****************
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>XML Data Binding Demo</title>
<xml id="data" src="data.xml">
<?xml version="1.0"?>
<employees>
<employee>
<lastName>Smith</lastName>
<firstName>Jill</firstName>
<title>President</title>
<department>All</department>
<extension>160</extension>
</employee>
<employee>
<lastName>Roberts</lastName>
<firstName>William</firstName>
<title>Vice President</title>
<department>Marketing</department>
<extension>175</extension>
</employee>
<employee>
<lastName>Gonzalez</lastName>
<firstName>Alejandra</firstName>
<title>Vice President</title>
<department>Sales</department>
<extension>188</extension>
</employee>
<employee>
<lastName>Billiker</lastName>
<firstName>Brian</firstName>
<title>Senior Software Architect</title>
<department>Information Systems</department>
<extension>176</extension>
</employee>
<employee>
<lastName>Williamson</lastName>
<firstName>Tara</firstName>
<title>Account Manager</title>
<department>Sales</department>
<extension>196</extension>
</employee>
</employees>
</xml>
<script language="JavaScript1.2">
function getRecords(){
for (i=0;i<3; i++) {
document.write ("<tr>");
document.write ("<td><span style='background: white; width:150; border-width:1'
dataSrc='#data' dataFld='lastName'></span> </td>");
document.write ("<td><span style='background: white; width:150; border-width:1'
dataSrc='#data' dataFld='firstName'></span> </td>");
document.write ("<td><span style='background: white; width:150; border-width:1'
dataSrc='#data' dataFld='title'></span> </td>");
document.write ("<td><span style='background: white; width:150; border-width:1'
dataSrc='#data' dataFld='department'></span> </td>");
document.write ("</tr>");
//alert(data.recordset.absoluteposition);
data.recordset.moveNext();
}
}
</script>
</head>
<body>
<h2 style="color: navy; font-family: Verdana,sans-serif"> Employee Directory
</h2>
<table border="0">
<tr bgcolor="ccccff">
<td class='text'><strong>Last name</strong></td>
<td class='text'><strong>First Name</strong></td>
<td class='text'><strong>Title</strong></td>
<td class='text'><strong>Department</strong></td>
</tr>
<script language="JavaScript">
getRecords()
</script>
</table>
</body>
</html>
***********************************
-
Re: How to show data island records through javascript
You're trying to do too much work. Let the data-binding mechanism do its
job. Delete the getRecords function and add the following HTML to define the
table.
<table border="0" datasrc="#data" datafield="employees">
<tr bgcolor="ccccff">
<td class='text'><strong>Last name</strong></td>
<td class='text'><strong>First Name</strong></td>
<td class='text'><strong>Title</strong></td>
<td class='text'><strong>Department</strong></td>
</tr>
<tr>
<td><span style='background: white; width:150; border-width:1'
dataSrc='#data' dataFld='lastName'></span> </td>
<td><span style='background: white; width:150; border-width:1'
dataSrc='#data' dataFld='firstName'></span> </td>
<td><span style='background: white; width:150; border-width:1'
dataSrc='#data' dataFld='title'></span> </td>
<td><span style='background: white; width:150; border-width:1'
dataSrc='#data' dataFld='department'></span> </td>
</tr>
</table>
"kamisetty" <kamisetty@email.com> wrote in message
news:3c62d6c8$1@10.1.10.29...
>
> Hi,
>
> I am trying to show all the data from xml thru javascript for loop. But I
> am getting always the absolute record data for all the rows. Please see
the
> fllowing code.
>
> Please help me.
>
>
> ********************************* CODE ****************
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
> <title>XML Data Binding Demo</title>
> <xml id="data" src="data.xml">
> <?xml version="1.0"?>
> <employees>
> <employee>
> <lastName>Smith</lastName>
> <firstName>Jill</firstName>
> <title>President</title>
> <department>All</department>
> <extension>160</extension>
> </employee>
> <employee>
> <lastName>Roberts</lastName>
> <firstName>William</firstName>
> <title>Vice President</title>
> <department>Marketing</department>
> <extension>175</extension>
> </employee>
> <employee>
> <lastName>Gonzalez</lastName>
> <firstName>Alejandra</firstName>
> <title>Vice President</title>
> <department>Sales</department>
> <extension>188</extension>
> </employee>
> <employee>
> <lastName>Billiker</lastName>
> <firstName>Brian</firstName>
> <title>Senior Software Architect</title>
> <department>Information Systems</department>
> <extension>176</extension>
> </employee>
> <employee>
> <lastName>Williamson</lastName>
> <firstName>Tara</firstName>
> <title>Account Manager</title>
> <department>Sales</department>
> <extension>196</extension>
> </employee>
> </employees>
> </xml>
> <script language="JavaScript1.2">
> function getRecords(){
> for (i=0;i<3; i++) {
> document.write ("<tr>");
> document.write ("<td><span style='background: white; width:150;
border-width:1'
> dataSrc='#data' dataFld='lastName'></span> </td>");
> document.write ("<td><span style='background: white; width:150;
border-width:1'
> dataSrc='#data' dataFld='firstName'></span> </td>");
> document.write ("<td><span style='background: white; width:150;
border-width:1'
> dataSrc='#data' dataFld='title'></span> </td>");
> document.write ("<td><span style='background: white; width:150;
border-width:1'
> dataSrc='#data' dataFld='department'></span> </td>");
> document.write ("</tr>");
> //alert(data.recordset.absoluteposition);
> data.recordset.moveNext();
> }
> }
> </script>
>
> </head>
>
> <body>
> <h2 style="color: navy; font-family: Verdana,sans-serif"> Employee
Directory
> </h2>
> <table border="0">
> <tr bgcolor="ccccff">
> <td class='text'><strong>Last name</strong></td>
> <td class='text'><strong>First Name</strong></td>
> <td class='text'><strong>Title</strong></td>
> <td class='text'><strong>Department</strong></td>
> </tr>
> <script language="JavaScript">
> getRecords()
> </script>
> </table>
> </body>
> </html>
> ***********************************
-
Re: How to show data island records through javascript
Russell,
Thanks for the response. it is working fine. My aim is to show some x records
per page from the xml document. Is there any way to show x records per page
on client side?
have a great day,
thanks,
kamisetty.
"Russell Jones" <arj1@northstate.net> wrote:
>You're trying to do too much work. Let the data-binding mechanism do its
>job. Delete the getRecords function and add the following HTML to define
the
>table.
>
><table border="0" datasrc="#data" datafield="employees">
> <tr bgcolor="ccccff">
> <td class='text'><strong>Last name</strong></td>
> <td class='text'><strong>First Name</strong></td>
> <td class='text'><strong>Title</strong></td>
> <td class='text'><strong>Department</strong></td>
> </tr>
> <tr>
> <td><span style='background: white; width:150; border-width:1'
>dataSrc='#data' dataFld='lastName'></span> </td>
> <td><span style='background: white; width:150; border-width:1'
>dataSrc='#data' dataFld='firstName'></span> </td>
> <td><span style='background: white; width:150; border-width:1'
>dataSrc='#data' dataFld='title'></span> </td>
> <td><span style='background: white; width:150; border-width:1'
>dataSrc='#data' dataFld='department'></span> </td>
> </tr>
></table>
>
>"kamisetty" <kamisetty@email.com> wrote in message
>news:3c62d6c8$1@10.1.10.29...
>>
>> Hi,
>>
>> I am trying to show all the data from xml thru javascript for loop. But
I
>> am getting always the absolute record data for all the rows. Please see
>the
>> fllowing code.
>>
>> Please help me.
>>
>>
>> ********************************* CODE ****************
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>"DTD/xhtml1-strict.dtd">
>> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
>> <head>
>> <title>XML Data Binding Demo</title>
>> <xml id="data" src="data.xml">
>> <?xml version="1.0"?>
>> <employees>
>> <employee>
>> <lastName>Smith</lastName>
>> <firstName>Jill</firstName>
>> <title>President</title>
>> <department>All</department>
>> <extension>160</extension>
>> </employee>
>> <employee>
>> <lastName>Roberts</lastName>
>> <firstName>William</firstName>
>> <title>Vice President</title>
>> <department>Marketing</department>
>> <extension>175</extension>
>> </employee>
>> <employee>
>> <lastName>Gonzalez</lastName>
>> <firstName>Alejandra</firstName>
>> <title>Vice President</title>
>> <department>Sales</department>
>> <extension>188</extension>
>> </employee>
>> <employee>
>> <lastName>Billiker</lastName>
>> <firstName>Brian</firstName>
>> <title>Senior Software Architect</title>
>> <department>Information Systems</department>
>> <extension>176</extension>
>> </employee>
>> <employee>
>> <lastName>Williamson</lastName>
>> <firstName>Tara</firstName>
>> <title>Account Manager</title>
>> <department>Sales</department>
>> <extension>196</extension>
>> </employee>
>> </employees>
>> </xml>
>> <script language="JavaScript1.2">
>> function getRecords(){
>> for (i=0;i<3; i++) {
>> document.write ("<tr>");
>> document.write ("<td><span style='background: white; width:150;
>border-width:1'
>> dataSrc='#data' dataFld='lastName'></span> </td>");
>> document.write ("<td><span style='background: white; width:150;
>border-width:1'
>> dataSrc='#data' dataFld='firstName'></span> </td>");
>> document.write ("<td><span style='background: white; width:150;
>border-width:1'
>> dataSrc='#data' dataFld='title'></span> </td>");
>> document.write ("<td><span style='background: white; width:150;
>border-width:1'
>> dataSrc='#data' dataFld='department'></span> </td>");
>> document.write ("</tr>");
>> //alert(data.recordset.absoluteposition);
>> data.recordset.moveNext();
>> }
>> }
>> </script>
>>
>> </head>
>>
>> <body>
>> <h2 style="color: navy; font-family: Verdana,sans-serif"> Employee
>Directory
>> </h2>
>> <table border="0">
>> <tr bgcolor="ccccff">
>> <td class='text'><strong>Last name</strong></td>
>> <td class='text'><strong>First Name</strong></td>
>> <td class='text'><strong>Title</strong></td>
>> <td class='text'><strong>Department</strong></td>
>> </tr>
>> <script language="JavaScript">
>> getRecords()
>> </script>
>> </table>
>> </body>
>> </html>
>> ***********************************
>
>
-
Re: How to show data island records through javascript
Sure, but not by binding. Your original looping code was close, but what you
want to do is just insert the field values for each cell rather than binding
the column to the dataset. I don't know if you're aware of it, but the data
island exposes a DOMDocument object, and you can use that with XPath queries
and XSLT to perform transforms against the data rather than treating the
data island as a dataset.
There's an example in an article I wrote for XML Magazine (August/Sept.
issue 2001) here. It's a Premier Club-only article though, so that might not
help you unless you're a member.
http://www.devx.com/premier/mgznarch...109/aj0109.asp
"kamisetty" <kamisetty@email.com> wrote in message
news:3c630bbe$1@10.1.10.29...
>
> Russell,
>
> Thanks for the response. it is working fine. My aim is to show some x
records
> per page from the xml document. Is there any way to show x records per
page
> on client side?
>
> have a great day,
>
> thanks,
> kamisetty.
>
> "Russell Jones" <arj1@northstate.net> wrote:
> >You're trying to do too much work. Let the data-binding mechanism do its
> >job. Delete the getRecords function and add the following HTML to define
> the
> >table.
> >
> ><table border="0" datasrc="#data" datafield="employees">
> > <tr bgcolor="ccccff">
> > <td class='text'><strong>Last name</strong></td>
> > <td class='text'><strong>First Name</strong></td>
> > <td class='text'><strong>Title</strong></td>
> > <td class='text'><strong>Department</strong></td>
> > </tr>
> > <tr>
> > <td><span style='background: white; width:150; border-width:1'
> >dataSrc='#data' dataFld='lastName'></span> </td>
> > <td><span style='background: white; width:150; border-width:1'
> >dataSrc='#data' dataFld='firstName'></span> </td>
> > <td><span style='background: white; width:150; border-width:1'
> >dataSrc='#data' dataFld='title'></span> </td>
> > <td><span style='background: white; width:150; border-width:1'
> >dataSrc='#data' dataFld='department'></span> </td>
> > </tr>
> ></table>
> >
> >"kamisetty" <kamisetty@email.com> wrote in message
> >news:3c62d6c8$1@10.1.10.29...
> >>
> >> Hi,
> >>
> >> I am trying to show all the data from xml thru javascript for loop. But
> I
> >> am getting always the absolute record data for all the rows. Please see
> >the
> >> fllowing code.
> >>
> >> Please help me.
> >>
> >>
> >> ********************************* CODE ****************
> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> >"DTD/xhtml1-strict.dtd">
> >> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> >> <head>
> >> <title>XML Data Binding Demo</title>
> >> <xml id="data" src="data.xml">
> >> <?xml version="1.0"?>
> >> <employees>
> >> <employee>
> >> <lastName>Smith</lastName>
> >> <firstName>Jill</firstName>
> >> <title>President</title>
> >> <department>All</department>
> >> <extension>160</extension>
> >> </employee>
> >> <employee>
> >> <lastName>Roberts</lastName>
> >> <firstName>William</firstName>
> >> <title>Vice President</title>
> >> <department>Marketing</department>
> >> <extension>175</extension>
> >> </employee>
> >> <employee>
> >> <lastName>Gonzalez</lastName>
> >> <firstName>Alejandra</firstName>
> >> <title>Vice President</title>
> >> <department>Sales</department>
> >> <extension>188</extension>
> >> </employee>
> >> <employee>
> >> <lastName>Billiker</lastName>
> >> <firstName>Brian</firstName>
> >> <title>Senior Software Architect</title>
> >> <department>Information Systems</department>
> >> <extension>176</extension>
> >> </employee>
> >> <employee>
> >> <lastName>Williamson</lastName>
> >> <firstName>Tara</firstName>
> >> <title>Account Manager</title>
> >> <department>Sales</department>
> >> <extension>196</extension>
> >> </employee>
> >> </employees>
> >> </xml>
> >> <script language="JavaScript1.2">
> >> function getRecords(){
> >> for (i=0;i<3; i++) {
> >> document.write ("<tr>");
> >> document.write ("<td><span style='background: white; width:150;
> >border-width:1'
> >> dataSrc='#data' dataFld='lastName'></span> </td>");
> >> document.write ("<td><span style='background: white; width:150;
> >border-width:1'
> >> dataSrc='#data' dataFld='firstName'></span> </td>");
> >> document.write ("<td><span style='background: white; width:150;
> >border-width:1'
> >> dataSrc='#data' dataFld='title'></span> </td>");
> >> document.write ("<td><span style='background: white; width:150;
> >border-width:1'
> >> dataSrc='#data' dataFld='department'></span> </td>");
> >> document.write ("</tr>");
> >> //alert(data.recordset.absoluteposition);
> >> data.recordset.moveNext();
> >> }
> >> }
> >> </script>
> >>
> >> </head>
> >>
> >> <body>
> >> <h2 style="color: navy; font-family: Verdana,sans-serif"> Employee
> >Directory
> >> </h2>
> >> <table border="0">
> >> <tr bgcolor="ccccff">
> >> <td class='text'><strong>Last name</strong></td>
> >> <td class='text'><strong>First Name</strong></td>
> >> <td class='text'><strong>Title</strong></td>
> >> <td class='text'><strong>Department</strong></td>
> >> </tr>
> >> <script language="JavaScript">
> >> getRecords()
> >> </script>
> >> </table>
> >> </body>
> >> </html>
> >> ***********************************
> >
> >
>
-
Re: How to show data island records through javascript
Russell,
Thank you. got the answer using Xpath/XSLT.
Have a Great day,
Kamisetty.
"Russell Jones" <arj1@northstate.net> wrote:
>Sure, but not by binding. Your original looping code was close, but what
you
>want to do is just insert the field values for each cell rather than binding
>the column to the dataset. I don't know if you're aware of it, but the data
>island exposes a DOMDocument object, and you can use that with XPath queries
>and XSLT to perform transforms against the data rather than treating the
>data island as a dataset.
>
>There's an example in an article I wrote for XML Magazine (August/Sept.
>issue 2001) here. It's a Premier Club-only article though, so that might
not
>help you unless you're a member.
>http://www.devx.com/premier/mgznarch...109/aj0109.asp
>
>
>"kamisetty" <kamisetty@email.com> wrote in message
>news:3c630bbe$1@10.1.10.29...
>>
>> Russell,
>>
>> Thanks for the response. it is working fine. My aim is to show some x
>records
>> per page from the xml document. Is there any way to show x records per
>page
>> on client side?
>>
>> have a great day,
>>
>> thanks,
>> kamisetty.
>>
>> "Russell Jones" <arj1@northstate.net> wrote:
>> >You're trying to do too much work. Let the data-binding mechanism do
its
>> >job. Delete the getRecords function and add the following HTML to define
>> the
>> >table.
>> >
>> ><table border="0" datasrc="#data" datafield="employees">
>> > <tr bgcolor="ccccff">
>> > <td class='text'><strong>Last name</strong></td>
>> > <td class='text'><strong>First Name</strong></td>
>> > <td class='text'><strong>Title</strong></td>
>> > <td class='text'><strong>Department</strong></td>
>> > </tr>
>> > <tr>
>> > <td><span style='background: white; width:150; border-width:1'
>> >dataSrc='#data' dataFld='lastName'></span> </td>
>> > <td><span style='background: white; width:150; border-width:1'
>> >dataSrc='#data' dataFld='firstName'></span> </td>
>> > <td><span style='background: white; width:150; border-width:1'
>> >dataSrc='#data' dataFld='title'></span> </td>
>> > <td><span style='background: white; width:150; border-width:1'
>> >dataSrc='#data' dataFld='department'></span> </td>
>> > </tr>
>> ></table>
>> >
>> >"kamisetty" <kamisetty@email.com> wrote in message
>> >news:3c62d6c8$1@10.1.10.29...
>> >>
>> >> Hi,
>> >>
>> >> I am trying to show all the data from xml thru javascript for loop.
But
>> I
>> >> am getting always the absolute record data for all the rows. Please
see
>> >the
>> >> fllowing code.
>> >>
>> >> Please help me.
>> >>
>> >>
>> >> ********************************* CODE ****************
>> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>> >"DTD/xhtml1-strict.dtd">
>> >> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
>> >> <head>
>> >> <title>XML Data Binding Demo</title>
>> >> <xml id="data" src="data.xml">
>> >> <?xml version="1.0"?>
>> >> <employees>
>> >> <employee>
>> >> <lastName>Smith</lastName>
>> >> <firstName>Jill</firstName>
>> >> <title>President</title>
>> >> <department>All</department>
>> >> <extension>160</extension>
>> >> </employee>
>> >> <employee>
>> >> <lastName>Roberts</lastName>
>> >> <firstName>William</firstName>
>> >> <title>Vice President</title>
>> >> <department>Marketing</department>
>> >> <extension>175</extension>
>> >> </employee>
>> >> <employee>
>> >> <lastName>Gonzalez</lastName>
>> >> <firstName>Alejandra</firstName>
>> >> <title>Vice President</title>
>> >> <department>Sales</department>
>> >> <extension>188</extension>
>> >> </employee>
>> >> <employee>
>> >> <lastName>Billiker</lastName>
>> >> <firstName>Brian</firstName>
>> >> <title>Senior Software Architect</title>
>> >> <department>Information Systems</department>
>> >> <extension>176</extension>
>> >> </employee>
>> >> <employee>
>> >> <lastName>Williamson</lastName>
>> >> <firstName>Tara</firstName>
>> >> <title>Account Manager</title>
>> >> <department>Sales</department>
>> >> <extension>196</extension>
>> >> </employee>
>> >> </employees>
>> >> </xml>
>> >> <script language="JavaScript1.2">
>> >> function getRecords(){
>> >> for (i=0;i<3; i++) {
>> >> document.write ("<tr>");
>> >> document.write ("<td><span style='background: white; width:150;
>> >border-width:1'
>> >> dataSrc='#data' dataFld='lastName'></span> </td>");
>> >> document.write ("<td><span style='background: white; width:150;
>> >border-width:1'
>> >> dataSrc='#data' dataFld='firstName'></span> </td>");
>> >> document.write ("<td><span style='background: white; width:150;
>> >border-width:1'
>> >> dataSrc='#data' dataFld='title'></span> </td>");
>> >> document.write ("<td><span style='background: white; width:150;
>> >border-width:1'
>> >> dataSrc='#data' dataFld='department'></span> </td>");
>> >> document.write ("</tr>");
>> >> //alert(data.recordset.absoluteposition);
>> >> data.recordset.moveNext();
>> >> }
>> >> }
>> >> </script>
>> >>
>> >> </head>
>> >>
>> >> <body>
>> >> <h2 style="color: navy; font-family: Verdana,sans-serif"> Employee
>> >Directory
>> >> </h2>
>> >> <table border="0">
>> >> <tr bgcolor="ccccff">
>> >> <td class='text'><strong>Last name</strong></td>
>> >> <td class='text'><strong>First Name</strong></td>
>> >> <td class='text'><strong>Title</strong></td>
>> >> <td class='text'><strong>Department</strong></td>
>> >> </tr>
>> >> <script language="JavaScript">
>> >> getRecords()
>> >> </script>
>> >> </table>
>> >> </body>
>> >> </html>
>> >> ***********************************
>> >
>> >
>>
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|