[AstroPy] getting id value from xml files

Michael Droettboom mdroe at stsci.edu
Fri Mar 27 09:43:12 EDT 2015


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>
|

The you could do:

|from astropy.io import votable
vot = votable.parse("file.xml")
value = vot.resources[0].infos[0].value
|

|astropy.io.votable| doesn’t currently have a “get info by ID” method, 
but those exist for some other things, so should probably be added. 
(I’ll make a PR and update you on that).

You could probably also do this with |astropy.io.votable| using Python’s 
built-in elementtree and XPath to match on the ID.

Mike

On 03/26/2015 07:47 PM, Grigoris Maravelias wrote:

> Hi to all!
>
> I have a quick question with probably a rather straightforward answer
> which probably may have slipped me.
> What is the fastest way to call the value of a field id in an xml file
> (produced by astropy).
>
> For example to get the value from the ID 'sfr'
> <INFO ID="sfr" name="sfr" value="1.34267351483e-40"/>
>
> Best
> Grigoris
>
>
> _______________________________________________
> 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/20150327/f6ea0b7e/attachment.html>


More information about the AstroPy mailing list