CSV/XML
- Started
- Last post
- 12 Responses
- ********
I've been given the choice of receiving some financial data in CSV or XML. I'll be importing it (trying to) to a site via PHP. Should I go for XML?
Also, I've never done this before and need a tutorial on how to parse XML and get the data and format the data and, basically, make use of it. I'd like to on-the-fly import it to MySQL which I understand.... but I expect that's not really how it's done....
A few pointers would be grand.
- ********0
...oh please.
*begs
- enobrev0
i would say go for xml, if at least to learn how. csv is easier but may not be robust enough for your needs. No way for me to tell.
When working with xml on php there's 2 major camps. DOM and SAX. In my experience, most servers have SAX installed and not DOM, although other's results may vary.
the DOM functions essentially break up your php document into a managable php object which you can use to access the data.
The SAX method gives you the proper tools needed to loop through the xml and create your object / array / etc according to your needs. This method seems to take a bit more work, but can be just as powerful. It's the method I've used most - due to server setups.
Here's a class that uses the sax method and creates an array for you to access the data
http://www.devdump.com/phpxml.ph…And here's some more info about sax based parsers from IBM
http://www-106.ibm.com/developer…And a pretty decent article comparing dom and sax (expat)
http://www.netmag.co.uk/tutorial…good luck!
- unfittoprint0
XML all the way.
CSV can't handle [or at least make it much more difficult] to deal with hierarchized structure, multiple levels of information.
- unfittoprint0
enobrev, can I mail u?
I'm having a problem regarding a WAMP testing server I created...
- enobrev0
of course man... also, have you checked out buzzard's wamp tutorial?
(searching for link)
link is a PDF:
http://www.blather.org/misc/WAMP…
- ********0
Thanks guys.
Looking at the XML route I think it's more than I may be able to cope with... Fuck.
I already figured out the CSV enough to realise that it's a short cut and not going to work.
Hmm. I expect I'll be back in here offering you some work.
- unfittoprint0
yeah, I already have it with me ;-)
It's just that I'm using Dreamweaver to compose my stuff. I also created a VirtualHost to a folder in C: root [htdocs in not very practical]:
-No problem regarding a php file [with or without MySQL]
_No problem regarding XML or HTML only files....
But, if I embed a flash file within any PHP or HTML file, the browser will not display the swf. The loading bar beneath stops at middway.... And if I test in firefox I get the message that the file wasn't found on the folder.
I used to be able to test a Flash+PHP+MySQL site within Apaches' htdocs why can't I do it in this VirtualHost....
any thoughts?
thx in advance....
- enobrev0
I'd reccommend a subfolder of C. It could potentially be perms or something. Probably not, but ya never know.
lemme see your httpd.conf
- unfittoprint0
i'll mail it to u in 5.
- ********0
*Bump
I've got this far..
http://sportech.design-portfolio…
How do I use that echo out the eight entries into a table or something? This shit hurts my head....
- unfittoprint0
didn't you to echo it as XML?
if so, use a while or a for in loop in php and constrcut each node:
( { and } stand for the "more than", "less than" symbols):$xml = "\n";
$xml .= "\n";
for(i=0, i{count($Array), i++){
$xml .= "{object id=\"".i."\" price=\"".$Array[i][0]."\" volume=\"".$Array[i][2]."\"
time=\"".$Array[i][4]."\" /}";
};
$xml .= "";echo $xml;
- ********0
Thanks ;)
I'll try this........