<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">VOTable is actually a container format
      for multiple tables, so you can only save that entire container to
      XML.<br>
      <br>
      The best thing to do to make modifications to save back out would
      be to retain a reference to the top-level VOTableFile object (not
      the votable.tree.Table object), and call `to_xml` on that.  That
      approach should also maintain all of the metadata (what the
      original names and IDs were).<br>
      <br>
      Hope that helps, and feel free to ping me if you need more detail.<br>
      <br>
      Mike<br>
      <br>
      On 02/25/2013 12:46 PM, Susana Sanchez wrote:<br>
    </div>
    <blockquote
cite="mid:CAK=du8+ddsNVLYvaKMrPcVDe9+Cj+ZMNKAPzjJMEVECVoV22Zg@mail.gmail.com"
      type="cite">
      <pre wrap="">Hi again,

This time I have the doubt saving votables as xml. As I said in my
previous mail, I want to show the VOTable in a nice way using Qt
library, I also want to allow the users can modify this votable and
then save the changes.

Reading the documentation I saw that the astropy.io.votable.tree.Table
has the method .to_xml, but probably I am not using it  well because I
get this error:

In [159]: table =
parse_single_table("/home/susana/Documents/guipsy/examples/tables/cig22.xml",pedantic=False)
In [160]: table.to_xml("./cig22_changed.xml")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/susana/<ipython console> in <module>()

/usr/local/lib/python2.6/dist-packages/astropy/io/votable/tree.pyc in
to_xml(self, w, **kwargs)
   2518
   2519     def to_xml(self, w, **kwargs):
-> 2520         with w.tag(
   2521             u'TABLE',
   2522             attrib=w.object_attrs(

AttributeError: 'str' object has no attribute 'tag'


Finally I got this way to save the xml:

#Open the votable
table = astropy.io.votable.parse_single_table("/home/susana/Documents/guipsy/examples/tables/cig22.xml",pedantic=False)

#Modify the table
table.array['CIG Number'][0]="CIG SUSANA"

#Create a VOTableFile instance of the table
votable= VOTableFile.from_table(table.to_table())

#Save the xml
votable.to_xml('cig22S.xml')


I have two questions/comments:

1) Is this way correct? Or maybe there is a better way to save the
changes made in a VOtable?

2) The VOTable created,  'cig22S.xml', is ok, but the fields have lost
the 'name' value. Now, the 'ID' and the 'name' have the same value
(the original value of ID).



Thanks again,
Susana.
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
AstroPy mailing list
<a class="moz-txt-link-abbreviated" href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/astropy">http://mail.scipy.org/mailman/listinfo/astropy</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>