The following code is taken from objectmodelhelper.cs (part of the
unittests) and dumps an atomfeed into a file:

 //////////////////////////////////////////////////////////////////////
       /// <summary>dump feeds</summary>
       /// <param name="theOne">the filenam</param>

//////////////////////////////////////////////////////////////////////
       public static void DumpAtomObject(AtomBase atom, string baseName)
       {
           if (atom != null)
           {
               StreamWriter stream = new StreamWriter(baseName, false,
System.Text.Encoding.UTF8);
               XmlTextWriter writer =  new XmlTextWriter(stream);
               writer.Formatting = Formatting.Indented;
               writer.WriteStartDocument(false);
               atom.SaveToXml(writer);
               writer.Flush();
               writer.Close();
               stream.Close();
           }
       }

/////////////////////////////////////////////////////////////////////////////

You need to start the document yourself - SaveToXml assumes a prepared
document, which makes it hence possible to embbed a feed inside something
else, if so desired...

Frank Mantek
Google

On 1/31/07, Filipe Alves Ferreira <[EMAIL PROTECTED]> wrote:
>
>
>
>  Hello,
>
> I can't do it as well.
> Best regards/Filipe
>
>  ------------------------------
>  > From: [EMAIL PROTECTED]
> > To: google-help-dataapi@googlegroups.com
> > Subject: SaveToXML
> > Date: Wed, 31 Jan 2007 18:02:34 +0000
> >
> >
> > Dear friends
> >
> > Is there any way i can get an XMLDocument using
> >
> > AtomFeed.SaveToXML(XmlWriter)
> >
> > I've tried:
> > AtomFeed calFeed = service.Query(query);
> > System.IO.MemoryStream mstream = new System.IO.MemoryStream();
> >
> > //calFeed.SaveToXml(mstream);
> >
> > System.Xml.XmlWriter writer = new XmlTextWriter(mstream,
> > System.Text.Encoding.UTF8);
> > calFeed.SaveToXml(writer);
> >
> > XmlDocument myDoc = new XmlDocument();
> > myDoc.Load(mstream);
> > writer.Close();
> >
> >
> > but fails in myDoc.Load(mstream) : no root element...
> >
> > Thank you in advance
> >
> >
> > Jesús de Diego
> >
> >
> > >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Data API" group.
To post to this group, send email to google-help-dataapi@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to