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
16
votes
3 answers

Proper name space management in .NET XmlWriter

I use .NET XML technologies quite extensively on my work. One of the things the I like very much is the XSLT engine, more precisely the extensibility of it. However there one little piece which keeps being a source of annoyance. Nothing major or…
Boaz
  • 25,331
  • 21
  • 69
  • 77
15
votes
1 answer

The prefix '' cannot be redefined from '' to 'http://www.sitemaps.org/schemas/sitemap/0.9' within the same start element tag

I'm getting this error The prefix '' cannot be redefined from '' to 'http://www.sitemaps.org/schemas/sitemap/0.9' within the same start element tag while running this code Dim writer As XmlWriter = XmlWriter.Create(FileLocation +…
umarali1
  • 153
  • 1
  • 1
  • 4
13
votes
1 answer

Replacing the innertext of an Xml node/element

First of all this is C#. I am creating a internet dashboard for a small group of colleages in the NHS. Below is an example xml file in which I need to change the innertext of. I need to replace a specific element for example "Workshop1." Because we…
Marshal
  • 1,177
  • 4
  • 18
  • 30
13
votes
2 answers

How to create an XML file from a XmlReader?

How do you write an XML file from an System.Xml.XmlReader? I thought this would be a simple question but whenever I search I seem to be ending up with reading the file to a reader or writing node by node. The XmlReader object conveys xml that was…
Andy
  • 2,248
  • 7
  • 34
  • 57
13
votes
3 answers

Removing version from xml file

I am creating a Xml like format using XmlWriter. But in the output there is version information also. I don't need this in my file. How can I do that? Is there any way to remove it by code?
viky
  • 17,275
  • 13
  • 71
  • 90
13
votes
2 answers

How can I remove the BOM from XmlTextWriter using C#?

How do remove the BOM from an XML file that is being created? I have tried using the new UTF8Encoding(false) method, but it doesn't work. Here is the code I have: XmlDocument xmlDoc = new XmlDocument(); XmlTextWriter xmlWriter = new…
Chris
  • 229
  • 2
  • 6
  • 14
12
votes
2 answers

XmlWriter encoding UTF-8 using StringWriter in C#

I'm using C# to output an xml file and Im trying to set the xml encoding value to UTF-8 but its currently outputting: This is my code: public sealed class StringWriterWithEncoding: StringWriter { private readonly Encoding…
Web Tech
  • 173
  • 1
  • 3
  • 11
12
votes
1 answer

XML writer and Memory Stream c#

I am creating a file using XmlWriter, XmlWriter writer = XmlWriter.Create(fileName); it is creating a file and then i have one more function which i am calling private void EncryptFile(string inputFile, string outputFile) which takes 2 string input…
SoftwareDeveloper
  • 175
  • 1
  • 1
  • 11
11
votes
1 answer

Output XMLWriter to XML file

I am currently using XMLWriter to display an xml file. However I would like to know how I could export the output to a .xml file. My current code is: $res = mysql_query($sql); $xml = new…
max_
  • 24,076
  • 39
  • 122
  • 211
11
votes
3 answers

Instruct XmlWriterSettings to use self-closing tags

I'm using XmlWriterSettings to write Xml to file. I have elements with only attributes, no children. I want them to output as: instead of Can i do it with XmlWriterSettings? EDIT: Code is as…
Istrebitel
  • 2,963
  • 6
  • 34
  • 49
10
votes
3 answers

string escape into XML-Attribute

I had a look at string escape into XML and found it very useful. I would like to do a similar thing: Escape a string to be used in an XML-Attribute. The string may contain \r\n. The XmlWriter class produces something like \r\n -> The…
Simon Ottenhaus
  • 715
  • 2
  • 8
  • 19
9
votes
5 answers

Appending an existing XML file with XmlWriter

I've used the following code to create an XML file: XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; xmlWriterSettings.NewLineOnAttributes = true; using (XmlWriter xmlWriter =…
user3105160
  • 307
  • 1
  • 4
  • 13
8
votes
2 answers

c# using + XmlWriter.Create = "Cannot access a closed Stream."

Why this works: using (var ms = new MemoryStream()) { using (var dummy = new StreamWriter(ms)) { var sw = new StreamWriter(ms); sw.WriteLine("Hello World"); sw.Flush(); using (StreamReader rdr = new…
Pol
  • 5,064
  • 4
  • 32
  • 51
8
votes
2 answers

Writing XMLDocument to file with specific newline character (c#)

I have an XMLDocument that I have read in from file. The file is Unicode, and has the newline character '\n'. When I write the XMLDocument back out, it has the newline characters '\r\n'. Here is the code, pretty simple: XmlTextWriter writer = new…
jaws
  • 1,952
  • 4
  • 20
  • 27
8
votes
5 answers

Create xml file with XmlWriter

I am having problems with the Create method in XmlWriter. Even when i use the example from msdn, it will not work. http://msdn.microsoft.com/en-us/library/kcsse48t.aspx I have created a "Blank page" project, for a windows store app. In it, ive…
Morten Toudahl
  • 452
  • 1
  • 4
  • 13
1
2
3
32 33