Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Parsing an XML file with namespace >Thread Next - Re: Parsing an XML file with namespace Re: Parsing an XML file with namespaceTo: 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. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
