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
8
votes
2 answers

I need multiple xmlns elements in an element with the XmWriter

I'm trying to convert a xml document from one format to another and while doing this I've found that I need to insert multiple xmlns declarations to the root element. Example:
user300112
8
votes
1 answer

Does the order of xmlns elements matter

I'm not sure how to search google for this but does the matter of the xmlns elements matter in an XML File? I'm creating a XML file using XMLWriter in ASP.NET(VB) and I'm trying to match an example I was provided.
gm77
  • 113
  • 1
  • 6
7
votes
1 answer

How can I coerce XmlWriter to handle namespaces correctly?

I want to use XmlWriter to write something like this (all in one namespace): but the closest I can seem to get is this:
lesscode
  • 6,221
  • 30
  • 58
7
votes
6 answers

what's the fastest way to write XML

I need create XML files frequently and I choose XmlWrite to do the job, I found it spent much time on things like WriteAttributeString ( I need write lots of attributes in some cases), my question is are there some better way to create xml files?…
Hiber
  • 464
  • 3
  • 11
7
votes
1 answer

How to use XDocument.Save to save a file using custom indentation for attributes

My goal is to output a modified XML file and preserve a special indentation that was present in the original file. The objective is so that the resulting file still looks like the original, making them easier to compare and merge through source…
A.Boulianne
  • 121
  • 7
7
votes
6 answers

XmlWriter writing empty xmlns

I'm using the following code to initialise an XmlDocument XmlDocument moDocument = new XmlDocument(); moDocument.AppendChild(moDocument.CreateXmlDeclaration("1.0", "UTF-8", null)); moDocument.AppendChild(moDocument.CreateElement("kml",…
stevehipwell
  • 56,138
  • 6
  • 44
  • 61
7
votes
1 answer

xmlwriter as input for xmlreader

I am trying to create a xml-structre from a name/value-pairs. This works with a xmlwriter. Now I would like to transform this xml. I think that the best way is to use the xmlwriter as source for the xmlreader to to the transform. But I don't know…
user1099480
  • 187
  • 1
  • 4
  • 11
7
votes
2 answers

How to check name of element with WriteEndElement

I'm writing xml with XmlWriter. My code has lots of sections like this: xml.WriteStartElement("payload"); ThirdPartyLibrary.Serialise(results, xml); xml.WriteEndElement(); // The problem is that the ThirdPartyLibrary.Serialise method is…
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
7
votes
0 answers

Make an XmlWriter output single quotes rather than double quotes around attribute values

Is there a way to make XmlWriter output single quotes rather than double quotes when writing attributes? I am not interested in XmlTextWriter which has a QuoteChar property (oddly not part of XmlWriterSettings). Also overriding some existing writer…
Marcus
  • 5,987
  • 3
  • 27
  • 40
6
votes
4 answers

XmlWriter encoding issues

I have the following code: MemoryStream ms = new MemoryStream(); XmlWriter w = XmlWriter.Create(ms); w.WriteStartDocument(true); w.WriteStartElement("data"); w.WriteElementString("child", "myvalue"); …
John
  • 17,163
  • 16
  • 65
  • 83
6
votes
3 answers

xmlwriter write elements in one line

I tried to save some elements from my application in xml file but when I started to develop it using this code : public static void WriteInFile(string savefilepath) { XmlWriter writer = XmlWriter.Create(savefilepath); …
kartal
  • 17,436
  • 34
  • 100
  • 145
6
votes
2 answers

Serialize Entity Framework object with children to XML file

I'm querying data with parent/child result sets using Entity Framework and I want to export this data to an XML document. var agreement = storeops.Agreements.SingleOrDefault(a => a.AgreementNumber == AgreementTextBox.Text); XmlSerializer serializer…
6
votes
0 answers

Why do I need to set XmlWriterSettings.Async to true to use async methods?

It's been a while since I last used XmlWriter but since today has been a lucky day to write some XML, so I started to use all the ...Async methods by default but straight away I get the following exception: System.InvalidOperationException : Set…
Kevin Smith
  • 13,746
  • 4
  • 52
  • 77
6
votes
2 answers

C# Parallel library, XmlReader, XmlWriter

I have a use case where I need to: iterate through each Input node in an Xml document perform a time-intensive calculation on each Input, and write the results to an XML file. Input looks something like this:
Eric Patrick
  • 2,097
  • 2
  • 20
  • 31
6
votes
1 answer

Return all attributes of an HtmlElement in Web browser

I need to get all of the attributes from my webbrowser.currently,I am using GetAttribute() but this way,I need to know the name of the attributes. Imagine I do not know what is in my webbrowser. My C# code: StringWriter strWriter = new…
Pedram
  • 728
  • 3
  • 10
  • 29
1 2
3
32 33