Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: XML Importing

  • To: mathgroup at
  • Subject: [mg49210] Re: XML Importing
  • From: Doug <umdougmm at>
  • Date: Wed, 7 Jul 2004 01:43:15 -0400 (EDT)
  • References: <cbe8ht$rl6$>
  • Sender: owner-wri-mathgroup at

Thanks to both you turns out the mathematica people noticed the
error and supposedly fixed it...
I just got an email yesterday, but haven't had time yet to look at it

"Michel, Hans J.I." <HMiche at LSUHSC.EDU> wrote in message
news:cbe8ht$rl6$1 at
> Doug:
> When I went to the following web site I did not get any xml data. I got
> Perl code and apparently directory browsing is enabled. It could be that
> site is under going maintenance
> +amd+mmm
> Even the sites homepage is down.
> As a result of the site being down the Perl code was available for
> So I took a look at the code. I came away with one central point. This
> just reformats yahoo finance stock quote code from cvs to xml.
> The crucial url is
> tickersymbol+tickersymbol
> Long of the short is You can use the Import with GetURL function which
> J/Link to retrieve stream from web via http. Or you can use the following
> trick
> getYahooData[ticker_] := Module[ {data, s, result},
> data = ImportString["<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE data
> '"; <>
> ToString[ticker] <> "'><!ELEMENT data (#PCDATA)>]><data>&text;</data>",
> "XML", ConversionOptions -> {"NormalizeWhitespace" -> False}];
> s = StringToStream[First[Cases[data, XMLElement["data",{}, ___],
> Infinity]][[3]][[1]]];
> result = ReadList[s,  Word, RecordSeparators -> {"\n"}, RecordLists
> -> True, WordSeparators -> ","];
>     Close[s];
>     TableForm[result]
>     ];
> getYahooData["msft+ibm"]
> As long as the cvs file does not contain the five unescaped SGML/XML
> entities {&,<,>,',",} well in this case {"} comes through.
> I output the result in table form but you can keep it as a list. Then use
> traditional Mathematica code to process and graph.
> Follows the following field format
> symbol ask qdate qtime change open dayhigh daylow volume
> good luck
> Hans Michel

  • Prev by Date: Re: Changing the Natural Sort Order
  • Next by Date: Re: Normal distribtion
  • Previous by thread: Re: sorting polynomials by the degree of certain terms
  • Next by thread: Vegas integration