How to get dynamic table in jQuery from xml -


I have an XML file and want to create dynamic HTML tables from the XML file. In the XML file there is a "header" for each node in "body".

The "headers" should have the node text as the first column in the form of RO and the value from "body". The second column, the golden target is inserted in the third column, depending on a CSS class value with an image Does I think that I should write a function for each value to get these rights?

How do I put it together to get a Jquery Code, to get the value of each node (body, headers), to get example table output? I'm absolutely a newbie in Jscripting.

Example output table example:

   & Lt; Td width = "33%" valign = "top" & gt; Value & lt; / Td> & Lt; Td width = "33%" valign = "top" & gt; Image & lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td width = "33%" valign = "top" & gt; Name & lt; / Td> & Lt; Td width = "33%" valign = "top" & gt; C & lt; / Td> & Lt; Td width = "33%" valign = "top" & gt; & Lt; IMG src = "" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td width = "33%" valign = "top" & gt; Computer type & lt; / Td> & Lt; Td width = "33%" valign = "top" & gt; C1 & lt; / Td> & Lt; Td width = "33%" valign = "top" & gt; & Lt; IMG src = "" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt;  

XML file:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; System name = "client" xmlns = "http: // ..." xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" & gt; & Lt; Header & gt; & Lt; C0> & Lt; Name & gt; Name & lt; / Name & gt; & Lt; / C0> & Lt; C1 & gt; & Lt; Name & gt; Computer type & lt; / Name & gt; & Lt; / C1> & Lt; C2 & gt; & Lt; Name & gt; CPU number & lt; / Name & gt; & Lt; / C2> & Lt; C3 & gt; & Lt; Name & gt; Total RAM & lt; / Name & gt; & Lt; / C3 & gt; & Lt; C4 & gt; & Lt; Name & gt; Hard disk & lt; / Name & gt; & Lt; / C4> & Lt; C5 & gt; & Lt; Name & gt; Logical drives & lt; / Name & gt; & Lt; / C5> & Lt; C6 & gt; & Lt; Name & gt; System drive free space & lt; / Name & gt; & Lt; / C6> & Lt; C7 & gt; & Lt; Name & gt; System drive usage & lt; / Name & gt; & Lt; / C7> & Lt; / Header & gt; & Lt; Body & gt; & Lt; R & gt; & Lt; C0> PC0001 & lt; / C0> & Lt; C1 & gt; Desktop & lt; / C1> & Lt; C2 & gt; 1 & lt; / C2> & Lt; C3 & gt; 858 99 345 9 2 & lt; / C3 & gt; & Lt; C4 & gt; & Lt; Disc & gt; & Lt; Manufacturer & gt; Western Digital & lt; / Creator & gt; & Lt; Name & gt; WDC WD5000AAKX-083CA0 & lt; / Name & gt; & Lt; Size & gt; 500105249280 & lt; / Size & gt; & Lt; / Disk & gt; & Lt; / C4> & Lt; C5 & gt; & Lt; Drive & gt; & Lt; Name & gt; C & lt; / Name & gt; & Lt; Sys> True & lt; / Sys & gt; & Lt; Size & gt; 400000282624 & lt; / Size & gt; & Lt; Free & gt; 345680142336 & lt; / Free & gt; & Lt; / Drive & gt; & Lt; Drive & gt; & Lt; Name & gt; D & lt; / Name & gt; & Lt; Sys> False & lt; / Sys & gt; & Lt; Size & gt; 100000591872 & lt; / Size & gt; & Lt; Free & gt; 99903418368 & lt; / Free & gt; & Lt; / Drive & gt; & Lt; / C5> & Lt; C6 & gt; 345,680,142,336 & lt; / C6> & Lt; C7 & gt; 13.6 & lt; / C7> & Lt; / R & gt; & Lt; / Body & gt;   

Update new junkie:

  $ (document) .ready (function () {$ .jax ({type : "GET", url: 'clients.xml', datatype: "xml", success: function (xml) {$ (xml) .find ("system"). Each (function () {Var LabelMetric = $ (this ) .find ('header') children () .text ($); $ (this) .fund ('body'). Children (). (Function () {var valueMetric = $ (('& lt; tr & Lt; td width = "33%" valign = "top" & gt; '+ label metric +' & lt; / td & gt; + & lt; td width = "33%" valign = "top" & Gt; '+ value metric +' & lt; / td & gt; & lt; / tr & gt; ';)}}}}}}}});});  
< / Div>


Comments