[AstroPy] getting id value from xml files
Michael Droettboom
mdroe at stsci.edu
Tue Mar 31 11:26:24 EDT 2015
On 03/29/2015 05:21 PM, Grigoris Maravelias wrote:
> Hi Mike! I just found time to check it...
>
> On 03/27/2015 02:43 PM, Michael Droettboom wrote:
>> The you could do:
>> |from astropy.io import votable
>> vot = votable.parse("file.xml")
>> value = vot.resources[0].infos[0].value|
> |I tried that but returns an error:
> |
> |ERROR: IndexError: list index out of range [__main__]
> Traceback (most recent call last):
> File "./xml_extractor.py", line 21, in <module>
> value = vot.resources[0].infos[0].value
> IndexError: list index out of range|
That was just an example if your file happened to have the same layout
as what I suggested -- since I hadn't seen your file, I just had to
guess. Chances are your INFO element in question is in a different
location, so you'll need to adjust accordingly.
>> I assume you are asking how to do this with astropy.io.votable?
>>
>> INFO tags can appear in a number of places in a VOTable file, so
>> without seeing the whole file, it’s hard to say.
>>
>> For example, if you had a file like:
>>
>> |<VOTABLE>
>> <RESOURCE>
>> <INFO ID="sfr" name="sfr" value="1.34267351483e-40"/>
>> </RESOURCE>
>> </VOTABLE>
>> |
> You are almost correct. I provide an original xml file (see [1])
I don't see the target of the citation (maybe just forgot?).
Cheers,
Mike
>
>
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20150331/95971567/attachment.html>
More information about the AstroPy
mailing list