xml-serialization

What is the best way to parse (big) XML in C# Code?

I'm writing a GIS client tool in C# to retrieve "features" in a GML-based XML schema (sample below) from a server. Extracts are limited to 100,000 features. I guestimate that the largest extract.xml might get up around 150 megabytes, so obviously DOM parsers are out I've been trying to decide between XmlSerializer and XSD.EXE generated ...

XmlDocument, XmlResolver and www.w3.org

Hello, One of my users had a single error while opening a file (I'm using standard xml 1.0): The remote name could not be resolved: 'www.w3.org' I found a post here in StackOverflow that deals with this and it suggest setting the XmlResolver property to null. I've tried this, and all my documents still seem to load fine. However, the...

Add prefix to XML Root Node - Implementation of Scott Hanselman's suggestion?

I would like to add a namespace prefix to the XML root node and I found an entry by Scott Hanselman which details exactly what I would like to achieve. The only problem being the implementation is missing ! Modifying the namespace PREFIX of the root node of the body of a SOAP Web Services Response....whew! It would be of great help i...

Precompile XmlSerializers with XmlAttributeOverrides

When constructing XmlSerializer instances in .NET, assemblies for serializing and deserializing the specified type are generated dynamically. This is a time-consuming process. The sgen.exe tool from Microsoft can be used to precompile XmlSerializer instances to use them later without generating them dynamically. Unfortunately this is not...

With partial classes, what controls order?

As discussed in http://stackoverflow.com/questions/431203/does-the-order-of-fields-in-c-matter, the order of serializable properties affects, among other things, XmlSerializer output. But if fields are in 2 files (using partial classes), does anyone know what in fact controls the resulting order? That is, which file's properties comes ...

How can I serialize a class with an attribute

I have a class that has [XmlRoot] <snip> [XmlAttribute(AttributeName="x:uid")] public string uid; <snip> It is OK At compile time.. however at runtime, exception occurs at line XmlSerializer serializer = new XmlSerializer(typeof(myClass)); because of the invalid character in "x:uid".. The element in my class needs to have an "x:u...

Is there a bug in XmlTextReader when opening empty datatables?

I'm having some issues using XmlSerializer and XmlTextReader in c# when saving DataTables which do not contain any data. Is this a known issue and is there a workaround? When an empty datatable is saved using XMLSerializer the following XML is generated: <Values> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3....

How to have an attribute on an element of type string

If I have [XmlElement(ElementName = "Title")] public string Title; How can i include an attribute in title without declaring a class (its type is just a string)?? so that when i serialize using XML serializer, the output is something like this: <Movie> <Title x:uid="movie_001">Armagedon</Title> <Date>010101</Date> <Movie> and n...

How can I Serialize Properly

If i have a class MovieClass as [XmlRoot("MovieClass")] public class Movie { [XmlElement("Novie")] public string Title; [XmlElement("Rating")] public int rating; } How can I have an attribute "x:uid" in my "Movie" element, so that the output when XmlSerializer XmlSerializer s = new XmlSerializer(typeof(MovieClass)) was u...

XML serialization question

Have an XML with next form: <categories someAttribute="test"> <category id="1"> <title></title> </category> <category id="1"> <title></title> </category> </categories> There is no way to change XML structure. But what I want is to replace buggy hand coded XML generation with XMLSerialization. Please help with those C...

How to make a value type nullable with .NET XmlSerializer?

Let's suppose I have this object: [Serializable] public class MyClass { public int Age { get; set; } public int MyClassB { get; set; } } [Serializable] public class MyClassB { public int RandomNumber { get; set; } } The XmlSerializer will serialize the object like that: <MyClass> <Age>0</age> <MyClassB> <R...

Can an XmlSerializer pool strings to avoid large duplicate strings?

I've got some very large XML files which I read using a System.Xml.Serialization.XmlSerializer. It's pretty fast (well, fast enough), but I want it to pool strings, as some long strings occur very many times. The XML looks somewhat like this: <Report> <Row> <Column name="A long column name!">hey</Column> <Column na...

XML Deserialization Permissions Error

I'm trying to use VS 2008 t publish a website to a virtual on my computer. The website runs just fine in VS2008 while debugging, but when I publish it, I'm getting the following error. Access to the path 'C:\dummy.xml' is denied. Description: An unhandled exception occurred during the execution of the current web request. Pl...

.net: how do debug XmlSerializer.Deserialize errors?

During development I've seen xml read errors like this more than once: TestData.ReadFromXml: xml Deserialize error:There is an error in XML document (2, 2).. What exactly does (2, 2) refer to? Is it line 2 in the xml file? Line 2, token 2, what? Are there any debug options I can add to shed more light on the problem? Edit: here are ...

XML serialize annotations

I have a situation where I have an xml file that I don't want to modify. The AddAnnotation function in XElement class provides an option to add memory-only data which is not serialized and not part of the XML. I want to be able to save these annotations (for example: to another xml file) and then to deserialize both the xml and the ann...

php array to xml, using same array key names

We are using pear's xml serializer to turn our request arrays into XML to submit to other servers for an XML response. The problem is, for one of the attributes we will need to submit an XML similar to this <totalRooms> <Room> ... </Room> <Room> ... </Room> </totalRooms> How do we compile this in PHP arrays so the Ser...

Scenarios where Xml Serialization fail in .NET

I would like to know the most common scenarios where xml serialization may fail in .NET. ...

Xmlserializer - Control Element-Attribute Pairing (revised)

The XmlSerializer does everything I want with one exception. I need to pair an element with another element as an attribute of that element. I don't want to write a completely custom serialize method. Here's my class: public class Transaction { [XmlElement("ID")] public int m_id; [XmlElement("TransactionType")] p...

Which SOAP XML object serialization library for Java would you recommend?

Which Java SOAP XML object serialization library would you recommend for Java object exchange with other platforms / languages (.NET, Delphi)? Communication scenarios could look like this: Java object writer -> SOAP XML text -> .NET or Delphi object reader .NET or Delphi object writer -> SOAP XML text -> Java object reader I know th...

How to use XMLSerializer with a Castle ActiveRecord containing an IList<T> member

I am trying to use the XMLSerializer with a castle active record class which looks like the following: [ActiveRecord("Model")] public class DataModel : ActiveRecordBase { private IList<Document> documents; [XmlArray("Documents")] public virtual IList<Document> Documents { get { return documents; } set ...