Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-16-2012, 05:33 AM   PM User | #1
varma51
New to the CF scene

 
Join Date: Jul 2012
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
varma51 is an unknown quantity at this point
Exclamation hi dis is varma..here is my xml data & i want to display this data in HTMl

gud morning frends i need ur valuable reply..here is my xml data i want to display dis data in the html table..so i need html code for to display dis data in the form of table..
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<?xml-stylesheet type="text/html" href="j.html"?>
<catalogs>
<catalog name="infibeam">
<book> 
<title>cnds</title>
<author>balagurusamy</author>
<company>zseries</company>
<country>america</country>
<price>
<mrp_price>150</mrp_price>
<discount>15%</discount>
</price>
</book>

<book> 
<title>java</title>
<author>chandrasekhar</author>
<company>qlines</company>
<country>england</country>
<price>
<mrp_price>15</mrp_price>
<discount>5%</discount>
</price>
</book>
<book> 
<title>oracle</title>
<author>somasekhar</author>
<company>MAster</company>
<country>australia</country>
<price>
<mrp_price>15</mrp_price>
<discount>5%</discount>
</price>
</book>
</catalog>

<catalog name="flipcart">
<book>
<title>C.N</title>
<author>varma</author>
<company>Vseries</company>
<country>india</country>
<price>
<mrp_price>150</mrp_price>
<discount>15%</discount>
</price>
</book>
<book>
<title>C.G</title>
<author>Eswar</author>
<company>kseries</company>
<country>india</country>
<price>
<mrp_price>200</mrp_price>
<discount>10%</discount>
</price>
</book>
</catalog>
</catalogs>

my required output lyk dis..

Code:
infibeam
TITLE   AUTHOR         COMPANY        COUNTRY
cnds    balagurusamy    zseries             america
java     chandrasekhar   qlines               england
oracle  somasekhar       MAster            australia

flipcart

TITLE   AUTHOR            COMPANY        COUNTRY
C.N      varma                  Vseries              india
C.G     Eswar                    kseries              india

Last edited by VIPStephan; 10-09-2012 at 11:46 PM.. Reason: added code BB tags
varma51 is offline   Reply With Quote
Old 07-16-2012, 08:10 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 361 Times in 360 Posts
sunfighter is on a distinguished road
Did you write the xml yourself? I ask because I am having a problem with the attribute
Code:
<catalog name="infibeam">
I would have done it differently:
use tags instead of an attribute.

Code:
<book>
<name>infibeam</name>
<title>cnds</title>
<author>balagurusamy</author>
<company>zseries</company>
<country>america</country>
<price>
<mrp_price>150</mrp_price>
<discount>15%</discount>
</price>
</book>
for eack <book> tag. Easier to render.
sunfighter is offline   Reply With Quote
Old 07-17-2012, 07:39 AM   PM User | #3
varma51
New to the CF scene

 
Join Date: Jul 2012
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
varma51 is an unknown quantity at this point
here iz my html code.i'm getting 2 tables i.e 1.infibeam 2.flipcart
but the reamaining data will be same in 2 tables..both d tables diasplay's all the attributes.... here iz my html code..plz make it corrections tahnqqqqq guysss..ur reply needed as early as possible.........


Code:
<!DOCTYPE html>
<html>
<body>

<script type="text/javascript">
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","d.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
  
  var y=xmlDoc.getElementsByTagName("catalog");
  for (j=0;j<y.length;j++)
{
  document.write(y[j].getAttribute("name"));

  document.write("<table border='1'>");
  document.write("</tr>");
  document.write("<tr><th>");
  document.write("title");
  document.write("</th><th>");
  document.write("author");
  document.write("</th><th>");
  document.write("company");
  document.write("</th><th>");
  document.write("country");
  document.write("</th></tr>");

var x=xmlDoc.getElementsByTagName("catalog");
{
var x=xmlDoc.getElementsByTagName("book");
{

for (i=0;i<x.length;i++)
{ 

  document.write("<tr><td>");
  document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
  document.write("</td><td>");
  document.write(x[i].getElementsByTagName("author")[0].childNodes[0].nodeValue);
  document.write("</td><td>");
  document.write(x[i].getElementsByTagName("company")[0].childNodes[0].nodeValue);
  document.write("</td><td>");
  document.write(x[i].getElementsByTagName("country")[0].childNodes[0].nodeValue);
  document.write("</td></tr>");
}
  }
}
document.write("</table>");
}


</script>
</body>
</html>

Last edited by VIPStephan; 10-09-2012 at 11:46 PM.. Reason: added code BB tags
varma51 is offline   Reply With Quote
Old 10-09-2012, 11:49 PM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,699
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Sorry, just noticed that last post got stuck in the moderation queue (along with a few duplicates) and therefore never got shown.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:07 PM.


Advertisement
Log in to turn off these ads.