Forums
This topic is locked
extracting and parsing data from text
Posted 30 Apr 2005 08:10:00
1
has voted
30 Apr 2005 08:10:00 Dan Berdusco posted:
i have a scenario where I download daily some currency rates from a website so that I can have up-to-date currency exchange on my site. Each day, i download some information, but I have yet to figure out how to extract certain parts of the data out of the file.For example, the data that I receive looks like this:
<pre id=code><font face=courier size=2 id=code><?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE xe-datafeed [
<!ELEMENT xe-datafeed (header*,currency*)>
<!ELEMENT header (hname,hvalue)>
<!ELEMENT hname (#PCDATA)>
<!ELEMENT hvalue (#PCDATA)>
<!ELEMENT currency (csymbol,cname,crate)>
<!ELEMENT csymbol (#PCDATA)>
<!ELEMENT cname (#PCDATA)>
<!ELEMENT crate (#PCDATA)>
]>
<xe-datafeed>
<header><hname>Version</hname><hvalue>2.45</hvalue></header>
<header><hname>Status</hname><hvalue>OK</hvalue></header>
<header><hname>Current UTC Time</hname><hvalue>2005.04.28 16:22:30</hvalue></header>
<header><hname>Notice</hname><hvalue>All use of this data is strictly regulated under the licensing Agreement. Unauthorized use is a breach of your duties and responsibilities under this Agreement.</hvalue></header>
<header><hname>Feed Expires on</hname><hvalue>April 19 2006</hvalue></header>
<header><hname>Days Remaining</hname><hvalue>356</hvalue></header>
<header><hname>UTC Time of Your Next Update</hname><hvalue>2005.04.29 12:00:00</hvalue></header>
<header><hname>Seconds Until Your Next Update</hname><hvalue>70650</hvalue></header>
<header><hname>Rate Format</hname><hvalue>XML</hvalue></header>
<header><hname>Rate Type</hname><hvalue>DAILY</hvalue></header>
<header><hname>Permitted accesses per week</hname><hvalue>9</hvalue></header>
<header><hname>Accesses so far this week</hname><hvalue>4</hvalue></header>
<header><hname>Accesses remaining in this week</hname><hvalue>5</hvalue></header>
<header><hname>Days until new access period begins</hname><hvalue>3</hvalue></header>
<header><hname>UTC Timestamp</hname><hvalue>2005.04.28 12:00:00</hvalue></header>
<header><hname>Local Timezone</hname><hvalue>UTC</hvalue></header>
<header><hname>Local Timestamp</hname><hvalue>2005.04.28 12:00:00</hvalue></header>
<header><hname>Base Currency</hname><hvalue>CAD</hvalue></header>
<currency><csymbol>AUD</csymbol><cname>Australia Dollars</cname><crate>1.0278093731</crate></currency>
<currency><csymbol>CAD</csymbol><cname>Canada Dollars</cname><crate>1.0000000000</crate></currency>
<currency><csymbol>CHF</csymbol><cname>Switzerland Francs</cname><crate>0.9530380354</crate></currency>
<currency><csymbol>EUR</csymbol><cname>Euro</cname><crate>0.6188866472</crate></currency>
<currency><csymbol>GBP</csymbol><cname>United Kingdom Pounds</cname><crate>0.4192512854</crate></currency>
<currency><csymbol>INR</csymbol><cname>India Rupees</cname><crate>34.9346500799</crate></currency>
<currency><csymbol>JPY</csymbol><cname>Japan Yen</cname><crate>84.6248555640</crate></currency>
<currency><csymbol>NZD</csymbol><cname>New Zealand Dollars</cname><crate>1.0998550822</crate></currency>
<currency><csymbol>USD</csymbol><cname>United States Dollars</cname><crate>0.7992918639</crate></currency>
<currency><csymbol>ZAR</csymbol><cname>South Africa Rand</cname><crate>4.8999331241</crate></currency>
</xe-datafeed>
</font id=code></pre id=code>
What I need to do, is extract certain rates (CAD, USD, and EURO) from the data and store them in variables so that I can use them with other applications.
My question is, does ASP have a built in function or some way to sort or parse this information, so that i CAN store certain portions in variables? Or does any one know any way to do this at all?
Any and all help is appreciated.
Thanks in advance.
Edited by - flexman44 on 30 Apr 2005 08:11:40
Replies
Replied 30 Apr 2005 19:07:39
30 Apr 2005 19:07:39 Chris Charlton replied:
I doubt ASP3 has a set of functions for this, but I may be wrong (*someone chime in*), since I would think ASP.NET is prepared for this. In regular ASP3, you could do string matching, but if you can find a mudule/component that allows you to parse in the whole XML file and pick out (easily) what you want, that's the way to go!
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Replied 03 May 2005 09:10:26
03 May 2005 09:10:26 Dan Berdusco replied:
Anybody want to offer some help on the .NET side of things. I am quite .NET illiterate.
Thank so much!
Edited by - flexman44 on 03 May 2005 09:10:57
Thank so much!
Edited by - flexman44 on 03 May 2005 09:10:57