javascript - Parsing XML to table with jQuery -


I am using YQL to drag into a remote XML feed, I have to work in all other areas, But can not get it Parsing the data and format in a table is here. The XML looks like this:

  & lt; String xmlns = "http://tempuri.org/" & gt; & Lt ;? XML version = "1.0" encoding = "UTF-16"? & Gt; & Lt; BTCE & gt; & Lt; TickerList / & gt; & Lt; Ticker & gt; & Lt; Average value = "" /> & Lt; BuyPrice value = "443.95" /> & Lt; Currency Value = "USD" /> & Lt; High Value = "456.96" /> & Lt; Low value = "424.00" /> & Lt; Cellpiece value = "444.27" /> & Lt; Quantity value = "18754.79784877" /> & Lt; Last price value = "443.95" /> & Lt; Time value = "04/28/2014 15:56:54" /> & Lt; / Ticker & gt; & Lt; Ticker & gt; & Lt; Average value = "" /> & Lt; BuyPrice value = "444.32" /> & Lt; Currency Value = "USD" /> & Lt; High Value = "456.96" /> & Lt; Low value = "424.00" /> & Lt; Cellpiece value = "444.70" /> & Lt; Quantity value = "18762.65028563" /> & Lt; Last price value = "443.96" /> & Lt; Time Value = "04/28/2014 15:57:57" /> & Lt; / Ticker & gt; & Lt; Ticker & gt; & Lt; Average value = "" /> & Lt; BuyPrice value = "444.32" /> & Lt; Currency Value = "USD" /> & Lt; High Value = "456.96" /> & Lt; Low value = "424.00" /> & Lt; Cellpiece value = "445.00" /> & Lt; Quantity value = "18758.16227820" /> & Lt; Last price value = "444.32" /> & Lt; Time Value = "04/28/2014 15:58:08" /> & Lt; / Ticker & gt; & Lt; / BTCE & gt;   

; & Lt; TR & gt; & Lt; Th & gt; Cost per / btc & lt; / Th & gt; & Lt; Th & gt; Quantity, ฿ & lt; / Th & gt; & Lt; Th & gt; Total, $ & lt; / Th & gt; & Lt; / TR & gt; & Lt; / Table & gt;

Trying to parse the XML like this:

  $ (function () {site = 'http: // ec2-54-201- 216-39.us-west-2.compute.amazonaws.com/testc/WebService.asmx/GetTicker '; var yql =' http://query.yahooapis.com/v1/public/yql?q='- Encoderic Silent ('Select * from XML where url = "' + + + site + '' ') +' & amp; format = xml & callback =? '; Function load tab () {$ .getJSON (yql, function (Data) {var xml = $ ParseXML (data.results [0]), xmlDoc = $ .parseXML ($ (xml). Find ("string"). Text ()), $ xml = $ (xmlDoc), $ BuyPrice = $ xml.find ("$ quantum = $ xml.find (" Volume "); $ sales process = $ xml.find (" SellPrice "); var tr; (var i = 0; i & lt; xml .length; i ++) {Tr = $ ('& Lt; tr / & gt; tr.append ('& lt; td & gt;' + $ buyprice.attr ("value") + '& lt; / td & gt;'); $ ('# BuyOrders') .append (tr);}})}} loadtable ();});  

It seems that you want to loop on each ticker Add a line for each one with Xml and related values:

  function loadTable () {$ .getJSON (yql, function (data) {var xml = $ .parseXML (data.results [0]), xmlDoc = $ .parseXML ($ (xml) .find ( "String"). Text ()), $ xml = $ (xmlDoc); $ Xml.find Ent ("value"); Var tr = $ ("& lt; tr / & gt;"); Trid ("Ticker"). Find ("buyprice") .append ("& lt; td" "+ buyprice +" ... any other TDS with different field values ​​here ... * / $ ("# BuyOrders").);});}); }  


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -