Questions tagged [xmldocument]

The original .NET type that represents an XML document. The more modern version is XDocument.

XmlDocument is the original .NET type that represents an XML document. The more modern version is XDocument.

Use XmlDocument.LoadXml to load an XmlDocument from a string. Use one of the XmlDocument.Load methods to load from a file path or URL, Stream, TextReader, or XmlReader.

Using XmlDocument.Load with a string containing XML will lead to the common "Data at the root level is invalid" exception.

1239 questions
7
votes
4 answers

How make XMLDocument do not put spaces on self-closed tags?

I have an XML well formatted without any spaces. It' must be like that. When I load it to XMLDocument to sign, the self-closing tags gets an extra white space and becomes: Once this document must be signed, it's…
João Vieira
  • 1,102
  • 1
  • 13
  • 17
7
votes
1 answer

How can I stop empty XML elements self-closing using XmlDocument in C#?

Before I get jumped on by people saying the XML parser shouldn’t care if the elements are empty or self-closed, there is a reason why I can’t allow self-closed XML elements. The reason is that I’m actually working with SGML not XML and the SGML DTD…
Can'tCodeWon'tCode
  • 543
  • 1
  • 11
  • 36
7
votes
3 answers

XElement to get all sub-element node names and values

I'm thinking of an approach something like this. Please let me know if this can actually work this way: For Sample XML: abc def 123 456
Loser Coder
  • 2,338
  • 8
  • 42
  • 66
7
votes
3 answers

Edit XML file in Windows Store app

I am making an app in windows store and having a problem in writing xml in created xml file. I have followed this Editing XML file in Windows Store App but it didn't work for me. I want this xml to be wrote in my xml file on button click. Any…
7
votes
6 answers

Java saying XML Document Not Well Formed

Java's XML parser seems to be thinking that my XML document is not well formed following the root element. But I've validated it with several tools and they all disagree. It's probably an error in my code rather than in the document itself. I'd…
Pyroclastic
  • 81
  • 1
  • 1
  • 3
7
votes
1 answer

How to select nodes where node name contains "mystring"

I need to get XmlNodeList where node name contains "mystring" XML node1 value node2 value node3 value
afin
  • 546
  • 3
  • 11
  • 21
7
votes
4 answers

Is XMLDocument.Save an atomic operation?

Is there anyway another process monitoring for files created using XMLDocument.Save() could encounter a partial file? Does it make any difference if Save() is overwriting an existing file?
JC.
  • 11,561
  • 11
  • 41
  • 50
7
votes
2 answers

Adding namespaces to XmlDocument using XmlNamespaceManager

I am trying to add namespaces to an XmlDocument using XmlNamespaceManager. This is the current xml: I would like it to transform to this xml (using…
user3062349
  • 691
  • 2
  • 7
  • 15
7
votes
2 answers

Removing CDATA tag from XmlNode

I have an XmlNode which represents the following xml for example: XmlNode xml.innerText = I want to change this node so that it'll contain the…
Niv
  • 2,294
  • 5
  • 29
  • 41
7
votes
2 answers

Access violation when using DocumentElement In XMLDocument

I always get an access violation when I try to use the DocumentElement of the XMLDocument. I create XMLDocument based on the existence of some file. Error message Project project1.exe raised exception class EAccessViolation with message 'Access…
Jatin Gera
  • 814
  • 1
  • 11
  • 25
7
votes
3 answers

How do I insert inner text into empty xml element?

I have an xmldocument that i'm loading xml in to. The xml looks like this: 0 CompanyA 123 Simpsons Dr. Springfield ST
user1750293
  • 73
  • 1
  • 4
6
votes
1 answer

XmlDocument ignore xmlns

I have XHTML file which starts with: I load it: XmlDocument xml = new XmlDocument(); StringReader sr = new StringReader(html); XmlTextReader xmltr = new XmlTextReader(sr); xmltr.Namespaces =…
Denis
  • 3,653
  • 4
  • 30
  • 43
6
votes
5 answers

Sort XML Nodes by Alpha.Numeric using C#

Say I have an XmlDocument that I generate that has InnerXml that looks like this: O01 13702
Vaccano
  • 78,325
  • 149
  • 468
  • 850
6
votes
2 answers

Which is the best for performance wise: XPathNavigator with XPath vs Linq to Xml with query?

I have an application in which I am using XPathNavigator to iterate nodes. It is working fine. But I want to know that if I use LINQ to Xml.... What benefits(Performance, maintainability) I will get? With XPath, LINQ to Xml what is the performance…
Syed
  • 931
  • 13
  • 28
6
votes
1 answer

Why is SelectSingleNode returning null?

I'm working with an XML document that contains a structure that looks similar to this: . . . I'm…
Todd Richardson
  • 1,119
  • 1
  • 11
  • 22