S
shapper
Hello,
I am creating an IHttp Handler that sends an XML file as response.
The XML file is created at runtime. I think the correct way is to save
it to a stream.
I have:
1 XDocument sitemap = new XDocument();
2 // Fill XDocument
3 Stream stream = new MemoryStream();
4 sitemap.Save(stream);
5 context.Response.Clear();
6 context.Response.ContentType = "text/xml; charset=utf-8";
7 context.Response.Write(stream);
8 context.Response.End();
But I am getting the following errors:
The best overloaded method match for
'System.Xml.Linq.XDocument.Save(System.Xml.XmlWriter)' has some
invalid arguments
Argument '1': cannot convert from 'System.IO.Stream' to
'System.Xml.XmlWriter'
I am trying to use XDocument to be able to use code that I already
created on my project where I use Linq:
XElement gallery = file.Document.Elements("gallery").FirstOrDefault();
XElement album = (from a in gallery.Elements("album")
where (Guid?)a.Attribute("id") == id
select a).FirstOrDefault();
album.Add(new XElement("img",
new XAttribute("id", paper.Slide.SlideID),
new XAttribute("caption", paper.Slide.Caption ?? ""),
new XAttribute("src", Path.GetFileName(paper.Slide.Path ?? "")),
));
How can I solve this?
Thanks,
Miguel
I am creating an IHttp Handler that sends an XML file as response.
The XML file is created at runtime. I think the correct way is to save
it to a stream.
I have:
1 XDocument sitemap = new XDocument();
2 // Fill XDocument
3 Stream stream = new MemoryStream();
4 sitemap.Save(stream);
5 context.Response.Clear();
6 context.Response.ContentType = "text/xml; charset=utf-8";
7 context.Response.Write(stream);
8 context.Response.End();
But I am getting the following errors:
The best overloaded method match for
'System.Xml.Linq.XDocument.Save(System.Xml.XmlWriter)' has some
invalid arguments
Argument '1': cannot convert from 'System.IO.Stream' to
'System.Xml.XmlWriter'
I am trying to use XDocument to be able to use code that I already
created on my project where I use Linq:
XElement gallery = file.Document.Elements("gallery").FirstOrDefault();
XElement album = (from a in gallery.Elements("album")
where (Guid?)a.Attribute("id") == id
select a).FirstOrDefault();
album.Add(new XElement("img",
new XAttribute("id", paper.Slide.SlideID),
new XAttribute("caption", paper.Slide.Caption ?? ""),
new XAttribute("src", Path.GetFileName(paper.Slide.Path ?? "")),
));
How can I solve this?
Thanks,
Miguel