Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Parsing an XML file with namespace

From: Peter Flynn <peter.nosp@-.--------.-->
To: NULL
Date: 9/21/2008 11:50:00 PM

Steve wrote:
> I am new to XML but have managed to parse most of the XML files I have
> come across within my javascript scripts. Until now. I am trying to
> parse the currency file available free from http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml
> The file looks like this:
> 
> <gesmes:Envelope>

Actually it doesn't. It starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" 
xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
	<gesmes:subject>Reference rates</gesmes:subject>

The root element shows the namespaces, so that you can instruct your 
processor that gesmes equates to "http://www.gesmes.org/xml/2002-08-01" 
and that the default namespace (used for all element types that do not 
have a prefix) is "http://www.ecb.int/vocabulary/2002-08-01/eurofxref"

///Peter

> <gesmes:subject>Reference rates</gesmes:subject>
> <gesmes:Sender>
> <gesmes:name>European Central Bank</gesmes:name>
> </gesmes:Sender>
> <Cube>
> <Cube time="2008-09-19">
> <Cube currency="USD" rate="1.4236"/>
> <Cube currency="JPY" rate="153.03"/>
> .......
> <Cube currency="THB" rate="48.630"/>
> <Cube currency="ZAR" rate="11.4902"/>
> </Cube>
> </Cube>
> </gesmes:Envelope>
> 
> I can parse the gesmes:subject and gesmes:name but I have no idea how
> to parse the <Cube> data, which is of course what I want. I have
> Googled around and this leads me to believe that this is a namespace
> issue but I cannot find out how to parse this within Javacript or if
> necessary PHP
> 
> Any help would be greatly appreciated, Steve.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent