I am attempting to store XML data from Yahoo, retrieved with YQL, in a MySQL database. I have a problem with Load XML because it does not appear to read child nodes. The XML file from which I am trying to extract the data is below. I require only the data from the 'Quotes', which is a child of 'result', and 'result' is a child of 'query'. If I edit the file and leave only the information enclosed in the 'result tag, the data is imported into the database just file
Is there some way that MySQL can get the data from the child nodes, or do I have to process the file first, such as reading it, and parsing it so that the only information I require is in the file? I.E, editing all of the XML files so that it contains only the information between the tag?
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://ift.tt/1apoFAW"
yahoo:count="4" yahoo:created="2014-09-30T00:36:42Z" yahoo:lang="en-US">
<diagnostics>
<url execution-start-time="1" execution-stop-time="37" execution-time="36"><![CDATA[http://ift.tt/1rGvlqH;
<publiclyCallable>true</publiclyCallable>
<url execution-start-time="41" execution-stop-time="80" execution-time="39"><![CDATA[http://ift.tt/YJi3h7;
<query execution-start-time="40" execution-stop-time="81"
execution-time="41" params="{url=[http://ift.tt/1rGvmec]}"><![CDATA[select * from csv where url=@url and columns='Ask,AverageDailyVolume,Bid,AskRealtime,BidRealtime,BookValue,Change&PercentChange,Change,Commission,Currency,ChangeRealtime,AfterHoursChangeRealtime,DividendShare,LastTradeDate,TradeDate,EarningsShare,ErrorIndicationreturnedforsymbolchangedinvalid,EPSEstimateCurrentYear,EPSEstimateNextYear,EPSEstimateNextQuarter,DaysLow,DaysHigh,YearLow,YearHigh,HoldingsGainPercent,AnnualizedGain,HoldingsGain,HoldingsGainPercentRealtime,HoldingsGainRealtime,MoreInfo,OrderBookRealtime,MarketCapitalization,MarketCapRealtime,EBITDA,ChangeFromYearLow,PercentChangeFromYearLow,LastTradeRealtimeWithTime,ChangePercentRealtime,ChangeFromYearHigh,PercebtChangeFromYearHigh,LastTradeWithTime,LastTradePriceOnly,HighLimit,LowLimit,DaysRange,DaysRangeRealtime,FiftydayMovingAverage,TwoHundreddayMovingAverage,ChangeFromTwoHundreddayMovingAverage,PercentChangeFromTwoHundreddayMovingAverage,ChangeFromFiftydayMovingAverage,PercentChangeFromFiftydayMovingAverage,Name,Notes,Open,PreviousClose,PricePaid,ChangeinPercent,PriceSales,PriceBook,ExDividendDate,PERatio,DividendPayDate,PERatioRealtime,PEGRatio,PriceEPSEstimateCurrentYear,PriceEPSEstimateNextYear,Symbol,SharesOwned,ShortRatio,LastTradeTime,TickerTrend,OneyrTargetPrice,Volume,HoldingsValue,HoldingsValueRealtime,YearRange,DaysValueChange,DaysValueChangeRealtime,StockExchange,DividendYield']]></query>
<javascript execution-start-time="39" execution-stop-time="105"
execution-time="65" instructions-used="200256" table-name="yahoo.finance.quote"/>
<user-time>106</user-time>
<service-time>75</service-time>
<build-version>0.2.2666</build-version>
</diagnostics>
<results>
<quote symbol="YHOO">
<AverageDailyVolume>31196000</AverageDailyVolume>
<Change>-0.14</Change>
<DaysLow>40.16</DaysLow>
<DaysHigh>41.09</DaysHigh>
<YearLow>31.70</YearLow>
<YearHigh>44.01</YearHigh>
<MarketCapitalization>40.301B</MarketCapitalization>
<LastTradePriceOnly>40.52</LastTradePriceOnly>
<DaysRange>40.16 - 41.09</DaysRange>
<Name>Yahoo! Inc.</Name>
<Symbol>YHOO</Symbol>
<Volume>35883248</Volume>
<StockExchange>NasdaqNM</StockExchange>
</quote>
<quote symbol="AAPL">
<AverageDailyVolume>54458800</AverageDailyVolume>
<Change>-0.64</Change>
<DaysLow>98.63</DaysLow>
<DaysHigh>100.435</DaysHigh>
<YearLow>67.7729</YearLow>
<YearHigh>103.74</YearHigh>
<MarketCapitalization>599.4B</MarketCapitalization>
<LastTradePriceOnly>100.11</LastTradePriceOnly>
<DaysRange>98.63 - 100.435</DaysRange>
<Name>Apple Inc.</Name>
<Symbol>AAPL</Symbol>
<Volume>49766312</Volume>
<StockExchange>NasdaqNM</StockExchange>
</quote>
<quote symbol="GOOG">
<AverageDailyVolume>1502650</AverageDailyVolume>
<Change>-0.74</Change>
<DaysLow>571.17</DaysLow>
<DaysHigh>578.19</DaysHigh>
<YearLow>502.80</YearLow>
<YearHigh>604.83</YearHigh>
<MarketCapitalization>389.8B</MarketCapitalization>
<LastTradePriceOnly>576.36</LastTradePriceOnly>
<DaysRange>571.17 - 578.19</DaysRange>
<Name>Google Inc.</Name>
<Symbol>GOOG</Symbol>
<Volume>1281204</Volume>
<StockExchange>NasdaqNM</StockExchange>
</quote>
<quote symbol="MSFT">
<AverageDailyVolume>33481000</AverageDailyVolume>
<Change>+0.03</Change>
<DaysLow>45.76</DaysLow>
<DaysHigh>46.56</DaysHigh>
<YearLow>32.70</YearLow>
<YearHigh>47.57</YearHigh>
<MarketCapitalization>382.7B</MarketCapitalization>
<LastTradePriceOnly>46.44</LastTradePriceOnly>
<DaysRange>45.76 - 46.56</DaysRange>
<Name>Microsoft Corpora</Name>
<Symbol>MSFT</Symbol>
<Volume>26090980</Volume>
<StockExchange>NasdaqNM</StockExchange>
</quote>
</results>
</query>
No comments:
Post a Comment