Questions tagged [xmlwriter]

System.Xml.XmlWriter class is part of .NET framework that provides non-cached, forward-only way to generate streams or files that contain XML data.

Documentation:

489 questions
58
votes
7 answers

Create XML in JavaScript

Is it possible to create an XML file with some data in JavaScript? I have the data stored in variables. I've googled around a bit and it doesn't seem like it's talked about much. I thought I could use XMLWriter such as this: var XML = new…
BigBug
  • 6,202
  • 23
  • 87
  • 138
51
votes
5 answers

How to create a XmlDocument using XmlWriter in .NET?

Many .NET functions use XmlWriter to output/generate xml. Outputting to a file/string/memory is a very operation: XmlWriter xw = XmlWriter.Create(PutYourStreamFileWriterEtcHere); xw.WriteStartElement("root"); ... Sometimes , you need to manipulate…
Boaz
  • 25,331
  • 21
  • 69
  • 77
39
votes
5 answers

How to put an encoding attribute to xml other that utf-16 with XmlWriter?

I've got a function creating some XmlDocument: public string CreateOutputXmlString(ICollection fields) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding =…
agnieszka
  • 14,897
  • 30
  • 95
  • 113
38
votes
6 answers

Why is the XmlWriter always outputting utf-16 encoding?

I have this extension method public static string SerializeObject(this T value) { var serializer = new XmlSerializer(typeof(T)); var settings = new XmlWriterSettings { …
Glenn Slaven
  • 33,720
  • 26
  • 113
  • 165
36
votes
6 answers

Indentation and new line command for XMLwriter in C#

I am writing some data to XML file...but when I open it all the values are in a single line...how can write it in readable format?ie each node in new line and indentation? FileStream fs = new FileStream("myfile.xml", FileMode.Create); XmlWriter w =…
Dark Knight
  • 3,507
  • 8
  • 35
  • 44
29
votes
1 answer

What is the difference between XmlTextWriter and XmlWriter?

I am looking at these these two classes in C#: XmlTextWriter and XmlWriter. Can anyone explain the difference and tell me where to use which?
Muhammad Basit
  • 291
  • 1
  • 3
  • 3
29
votes
3 answers

Adding multiple namespace declarations in XmlWriter

I am trying to write out the following element using XmlWriter I've got…
etechpartner
  • 640
  • 1
  • 7
  • 12
26
votes
7 answers

Can we force XmlWriter to issue rather than ?

By default, someXmlWriter.WriteElementString("my-tag", someString); produces I looked around XmlWriterSettings class for possible options that would force the writer to produce instead but didn't find anything. Is…
mjv
  • 73,152
  • 14
  • 113
  • 156
26
votes
4 answers

How to enable xmlwriter after PHP having been compiled?

I've got a message that ext/xmlwriter is missing while trying to set up phpMyFAQ on my system of Fedora 15. I looked it up on the PHP manual and got this: This extension is enabled by default. It may be disabled by using the following option at…
lastland
  • 890
  • 3
  • 14
  • 28
25
votes
3 answers

how to create an xml using xml writer without declaration element

I am using XmlWriter.Create() to get a writer instance then write the XML, but the result has the , how do I tell my xml writer do not produce it?
ninithepug
  • 253
  • 1
  • 3
  • 4
21
votes
4 answers

Possible to write XML to memory with XmlWriter?

I am creating an ASHX that returns XML however it expects a path when I do XmlWriter writer = XmlWriter.Create(returnXML, settings) But returnXML is just an empty string right now (guess that won't work), however I need to write the XML to…
MetaGuru
  • 42,847
  • 67
  • 188
  • 294
20
votes
2 answers

How do I set the Settings property in XmlTextWriter, so that I can write each XML attribute on its own line?

I have this bit of code, which serializes an object to a file. I'm trying to get each XML attribute to output on a separate line. The code looks like this: public static void ToXMLFile(Object obj, string filePath) { XmlSerializer serializer =…
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
20
votes
4 answers

Writing formatted XML with XmlWriter

I'm trying to write to an XML file to the isolated storage but I would like to format it like this:-
None
  • 203
  • 1
  • 2
  • 5
17
votes
2 answers

Serialization of object to xml and string without \r\n special characters

I want to serialize my object to xml and then to a string. public class MyObject { [XmlElement] public string Name [XmlElement] public string Location; } I want to obtain a single line string which will lok like…
Wodzu
  • 6,932
  • 10
  • 65
  • 105
16
votes
2 answers

XMLWriter vs XMLDictionaryWriter

What's the difference between XMLWriter and XMLDictionaryWriter? In which cases is each one generally used?
JRS
  • 1,438
  • 2
  • 16
  • 26
1
2 3
32 33