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

C# extracting data from XML

I'm trying to read weather data from XML in a URL. The XML looks like this: ... ... ... ...
user1810659
  • 221
  • 2
  • 7
  • 18
12
votes
2 answers

XmlDocument Save keeps file open

I have a simple c# function that creates a basic XML file and saves: private void CreateXMlFile(string Filename, string Name, string Company) { XmlDocument doc = new XmlDocument(); XmlNode docNode =…
Belliez
  • 5,356
  • 12
  • 54
  • 62
12
votes
2 answers

Why does XmlDocument.LoadXml throw System.Net.WebException?

Why does System.Xml.XmlDocument.LoadXml method throw System.Net.WebException ? This is really mind boggling crazy, if MSDN was right, LoadXml should at most give me a System.Xml.XmlException. Yet I have weird exceptions like: The underlying…
Pacerier
  • 86,231
  • 106
  • 366
  • 634
12
votes
1 answer

Error :- The XmlReader state should be Interactive on XDocument.Load

I get the following error :- System.InvalidOperationException: The XmlReader state should be Interactive. at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o) at System.Xml.Linq.XDocument.Load(XmlReader reader,…
Ashish Gupta
  • 14,869
  • 20
  • 75
  • 134
12
votes
1 answer

add a root element using xmldocument in C#.net

I need to create an XML file using an xmldocument object in C#. How can I add a root element like: book:aaaa xsi:schemalocationchemaLocation="http://www.com"
Rakesh kumar
  • 121
  • 1
  • 1
  • 4
11
votes
1 answer

How to Select XML Nodes with XML Namespaces from an XmlDocument?

my code attempts to grab data from the RSS feed of a website. It grabs the nodes fine, but when attempting to grab the data from a node with a colon, it crashes and gives the error "Namespace Manager or XsltContext needed. This query has a prefix,…
Sticky
  • 1,022
  • 1
  • 11
  • 19
11
votes
5 answers

Decode CDATA section in C#

I have a bit of XML as follows:
I'm accessing it using curXmlNode.SelectSingleNode("description").InnerText but…
Jess
  • 42,368
  • 6
  • 37
  • 51
11
votes
3 answers

Name cannot begin with the '1' character, hexadecimal value 0x31. Line 2, position 2

While loading XML file in a C# application, I am getting Name cannot begin with the '1' character, hexadecimal value 0x31. Line 2, position 2. The XML tag begins like this.
aWebdesigner09
  • 257
  • 2
  • 5
  • 17
10
votes
3 answers

How to programmatically modify assemblyBinding in app.config?

I am trying to change the bindingRedirect element at install time by using the XmlDocument class and modifying the value directly. Here is what my app.config looks like:
esac
  • 24,099
  • 38
  • 122
  • 179
10
votes
3 answers

XmlDocument throwing "An error occurred while parsing EntityName"

I have a function where I am passing a string as params called filterXML which contains '&' in one of the properties. I know that XML will not recognize it and it will throw me an err. Here is my code: public XmlDocument TestXMLDoc(string…
RG-3
  • 6,088
  • 19
  • 69
  • 125
9
votes
3 answers

How to remove encoding="UTF-8" standalone="no" from xml Document object in Java

I want to create XML in Java. DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; docBuilder = dbfac.newDocumentBuilder(); Document doc = docBuilder.newDocument(); but Java…
VextoR
  • 5,087
  • 22
  • 74
  • 109
9
votes
2 answers

insert XmlDocument into a XmlDocument node

I created a basic XmlDocument with one node: XmlDocument bigDoc = new XmlDocument(); bigDoc.LoadXml(""); and I'm getting another XmlDocument that I want to insert inside node. It doesn't work for me: XmlNode…
Rodniko
  • 4,926
  • 20
  • 69
  • 93
9
votes
1 answer

GetElementsByTagName which is not case sensitive?

i'm using GetElementsByTagName to extract an element from an xml. GetElementsByTagName is case sensitive - it throws an exception if the node name is 'PARAMS' instead of 'Params'. i dont want that , can i use a different way in XMLDocument so it…
Rodniko
  • 4,926
  • 20
  • 69
  • 93
9
votes
4 answers

XmlDocument.WriteTo truncates resultant file

Trying to serialize an XmlDocument to file. The XmlDocument is rather large; however, in the debugger I can see that the InnerXml property has all of the XML blob in it -- it's not truncated there. Here's the code that writes my XmlDocument object…
Brad Heller
  • 1,551
  • 5
  • 18
  • 29
9
votes
1 answer

System.Xml.XmlException - Root element is missing

I am making a web application that takes RSS feeds from websites(URLs are in database) and then loads them into my web application. But I am getting this error System.Xml.XmlException: Root element is missing. root element is missing. at line :…
ra22
  • 133
  • 1
  • 3
  • 7