Is your application WPF or Silverlight?The XLMWriter class is depending on this.With Silverlight, you can't create an XMLWriter writing to a file.So your code should be OK with WPF but not with Silverlight: string xmlfile = @layer1_xml.xml; using (XmlWriter writer = XmlWriter.Create(xmlfile, settings )) With SL, you need a stream as argument.Something like: string dataFile = @graphics.xml; using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream fileStream = store.CreateFile(dataFile)) { using (XmlWriter writer = XmlWriter.Create(fileStream, new XmlWriterSettings() { Indent = true })) { graphicsLayer.SerializeGraphics(writer); writer.Close(); } fileStream.Close(); }�??
string xmlfile = @layer1_xml.xml; using (XmlWriter writer = XmlWriter.Create(xmlfile, settings ))
string dataFile = @graphics.xml; using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream fileStream = store.CreateFile(dataFile)) { using (XmlWriter writer = XmlWriter.Create(fileStream, new XmlWriterSettings() { Indent = true })) { graphicsLayer.SerializeGraphics(writer); writer.Close(); } fileStream.Close(); }�??
This seems like a related thread, kindly see: http://forums.arcgis.com/threads/8774-save-layer-to-xml-fileWhile you will not be saving an entire layer to XML, the idea is the same, instead of layer.Graphics you will be using ESRI.ArcGIS.Client.Tasks.QueryEventArgs args.FeatureSet.FeatureSet.
XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = ""; settings.NewLineOnAttributes = true; //Using XmlWriter to create xml file //using (XmlWriter writer=XmlWriter .Create("C:\xmlfile.xml",XmlWriterSettings)) string xmlfile = @layer1_xml.xml; using (XmlWriter writer = XmlWriter.Create(xmlfile, settings )) { writer.WriteComment ("Cutting results from layer1"); writer.WriteStartElement ("Results Details"); writer.WriteAttributeString (featureSet.Features[0].Attributes.ElementAt(0).Key.ToString(),featureSet.Features[0].Attributes.ElementAt(0).Value.ToString()); writer.WriteEndElement(); //writer.Flush ; }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.