Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,089
    Thanks
    23
    Thanked 593 Times in 592 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,627
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Sorry, just noticed that last post got stuck in the moderation queue (along with a few duplicates) and therefore never got shown.


  •  

    Posting Permissions

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