xmldocument

XmlDocument - ParentNode and DocumentType are null

In .NET what does it mean if you LoadXml() into the XmlDocument object and then ParentNode and DocumentType are null? Also, I get this as the answer to xmldoc.FirstChild.Value: version="1.0" encoding="utf-8" Is this right? Been a while since I have done any XML DOM stuff. The file is encoded UTF-8. Think that shouldn't be an issue. I...

How can I navigate deeper in XML and append data in it

I have loaded XmlDocument into memory and created new XmlElement. Now I am trying to add XmlElement to the path /report/section/hosts but I don't know how. I can add it easily below root node of XML but I cannot figure out how can I navigate deeper level in XML and just append there. In pseudo I am trying to do this: doc.SelectNodes("/...

ASP.NET: Will Saving an XmlDocument to the Response.OutputStream honor the encoding?

i want to send the xml of an XmlDocument object to the HTTP client, but i'm concerned that the suggested soltuion might not honor the encoding that the Response has been set to use: public void ProcessRequest(HttpContext context) { XmlDocument doc = GetXmlToShow(context); context.Response.ContentType = "text/xml"; context.Resp...

Library to generate .NET XmlDocument from HTML tag soup

I'm looking for a .NET library that can generate a clean Xml tree, ideally System.Xml.XmlDocument, from invalid HTML code. I.E. it should make the kind of best effort guesses, repairs, and substitutions browsers do when confronted with this situation, and generate a pretend XmlDocument. The library should also be well-maintained. :) I...

Ajax request and text/xml

I am requesting and xml file over ajax, the server uses the header text/xml for the data returned. Firefox reads this header and turns the data into an XMLDocument object which means I can't use it with jQuery. How can I get my XML document as plain text? ...

When do you use XPath over XmlDocument or XmlTextReader?

When do you use XPath over XmlDocument? I'm trying to see things from a higher level. Is there a situation where it is better to use XPath over XmlDocument? ...

Serialise object to XmlDocument

In order to return useful information in SoapException.Detail for an asmx web service, I took an idea from WCF and created a fault class to contain said useful information. That fault object is then serialised to the required XmlNode of a thrown SoapException. I'm wondering whether I have the best code to create the XmlDocument - here ...

To fetch the attributes from the NodeList of XmlDocument?

Hi Everyone, I have part of XmlDocument Example.xml as given below: <rapaine dotoc="palin" domap="rattmin"> <derif meet="local" /> <derif meet="intro" /> . . . </rapaine> Here i am creating a Nodelist and fetching the element raplin to get its attributes. Now i want to make sure that whether the attributes 'dotoc' and 'domap' a...

Root element is missing error for .net XmlDocument.load()

Greetings all. I'm getting an asp.net error "Root element is missing" when I load the results of a REST request into an XmlDocument. The same REST request looks fine and returns valid results when I execute it using the Firefox addon "RESTTEST". But the error shows up in the C#.net code-behind. Does anyone know what might cause this?...

How to programatically 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: <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Cu...

Why is SelectSingleNode returning null?

I'm working with an XML document that contains a structure that looks similar to this: <MT> <Events> <event id="1"> <field name="blah" value="a_value" type="atype" /> . . . </event> </Events> </MT> I'm currently loading this from a file into an XML document in this fashion: XmlDocument xdoc = ne...

C# XMLDocument to DataTable?

I assume I have to do this via a DataSet, but it doesn't like my syntax. I have an XMLDocument called "XmlDocument xmlAPDP". I want it in a DataTable called "DataTable dtAPDP". I also have a DataSet called "DataSet dsAPDP". - if I do DataSet dsAPDP.ReadXML(xmlAPDP) it doesn't like that because ReadXML wants a string, I assume a file...

Dynamically generating RDLC - What stops me from using a StringBuilder for building the XML

Hi I'm building a Local Report. Because of some limitations of the Hidden property, I need to dynamically generate the report. I found some documentation here. The ReportViewer Control needs a stream. I don't really like the method that's used in the documentation. And building an XmlDocument isn't very readable imo. Is there some...

System.Xml.XmlDocument, what's the best way to cache an external dependency DTD?

I'm loading valid XHTML into an XmlDocument, but it takes 2 seconds to load. I've found that if I drop the DTD, it's instant, but then I have to replace &nbsp; to &#160;, etc. The number of declared HTML entities is large, so I feel the DTD should be loaded. So what is the easiest way to pre-load the DTD with minimal manual labor? Perhap...

C#: Read XML Attribute using XmlDocument

How can I read an XML attribute using C#'s XmlDocument? I have an XML file which looks somewhat like this: <?xml version="1.0" encoding="utf-8" ?> <MyConfiguration xmlns="http://tempuri.org/myOwnSchema.xsd" SuperNumber="1" SuperString="whipcream"> <Other stuff /> </MyConfiguration> How would I read the XML attributes SuperNumbe...

Disable the reference to entity with XML

I am currently working on program that must read data from a XML stream that some time may contains '&' symbols i.e : <XMLRoot> <Element> <Node> This is a dummy data&more! </Node> </Element> </XMLRoot> When I parse this text I get an error message telling me 'reference to undeclare entity'. Is the...

Relative XPath node selection with C# XmlDocument

Imagine the following XML document: <root> <person_data> <person> <name>John</name> <age>35</age> </person> <person> <name>Jim</name> <age>50</age> </person> </person_data> <locations> <location> <name>John</name> ...

C#: wcf return an XmlDocument?

Duplicate: serializing-generic-xml-data-across-wcf-web-service-requests Hi all, I have a WCF service where Im building up a block of XML using an XmlWriter. Once complete I want to have the WCF return it as an XmlDocument. But if I have XmlDocument in the [OperationContract] it doesnt work: [OperationContract] XmlDocument GetNex...

C# - Parse malformed XML

I'm trying to load a piece of (possibly) malformed HTML into an XMLDocument object, but it fails with XMLExceptions... since there are extra opening/closing tags, and malformed XML tags such as <img > instead of <img /> How do I get the XML to parse with all the errors in the data? Is there any XML validator that I can apply before pars...

What is an appropriate XML type for web service?

Current Implementation Sql Server 2005 Database with a table called messages with a column called MessageXml of type xml. C# Library project with a Linq to Sql class that generates a class called Message with a field called MessageXml of type XElement. WCF Webservice that exposes a MessagePayload class with a property called MessageXm...