xml

C#: instantiating classes from XML

What I have is a collection of classes that all implement the same interface but can be pretty wildly different under the hood. I want to have a config file control which of the classes go into the collection upon starting the program, taking something that looks like <class1 prop1="foo" prop2="bar"/> and turning that into blah = ne...

Preventing XML Serialization of IEnumerable and ICollection<T> & Inherited Types

NOTE: XMLIgnore is NOT the answer! OK, so following on from my question on XML Serialization and Inherited Types, I began integrating that code into my application I am working on, stupidly thinking all will go well.. I ran into problems with a couple of classes I have that implement IEnumerable and ICollection<T> The problem with the...

Algorithmic complexity of XML parsers/validators

I need to know how the performance of different XML tools (parsers, validators, XPath expression evaluators, etc) is affected by the size and complexity of the input document. Are there resources out there that document how CPU time and memory usage are affected by... well, what? Document size in bytes? Number of nodes? And is the relati...

XML Schema construct for "Any number of these elements - in any order"

I need to create an XML schema that looks something like this: <xs:element name="wrapperElement"> <xs:complexType> <xs:sequence> <xs:element type="el1"> <xs:element type="el2"> </xs:sequence> <xs:WhatGoesHere?> <xs:element type="el3"> <xs:element type="el4"> <xs:element type="el5"> ...

XML Parser Validation Report

Most XML parsers will give up after the first error in a document. In fact, IIRC, that's actually part of the 'official' spec for parsers. I'm looking for something that will break that rule. It should take a given schema (assuming a valid schema) and an xml input and attempt to keep going after the first error and either raise an e...

How do I load an org.w3c.dom.Document from XML in a string?

I have a complete XML document in a string and would like a Document object. Google turns up all sorts of garbage. What is the simplest solution? (In Java 1.5) Solution Thanks to Matt McMinn, I have settled on this implementation. It has the right level of input flexibility and exception granularity for me. (It's good to know if the err...

XML attribute vs XML element

At work we are being asked to create XML files to pass data to another offline application that will then create a second XML file to pass back in order to update some of our data. During the process we have been discussing with the team of the other application about the structure of the XML file. The sample I came up with is essentia...

Microsoft Office 2007 automated installation - editing the config.xml file

Hi all I'm creating an automated installation of Office 2007. To customise your Office 2007 installation the Office Customization Tool (OCT) does most of the work for you. One the OCT's features is the ability to run additional programs during the Office installation. However it is pretty poor at it. Fortunately by editing the app...

How to apply an XSLT Stylesheet in C#

I want to apply an XSLT Stylesheet to an XML Document using C# and write the output to a File. Edit: @Rob Cooper: Yes, I am aware of that. But I couldn't find it in SO. The Idea of this site is to collect answers to any question a developer could have, right? I had this question today and thus posted an answer. Next time I look (this i...

How do you use XML::Parser with Style => 'Objects'

The manual page for XML::Parser::Style::Objects is horrible. A simple hello world style program would really be helpful. I really wanted to do something like this: (not real code of course) use XML::Parser; my $p = XML::Parser->new(Style => 'Objects', Pkg => 'MyNode'); my $tree = $p->parsefile('foo.xml'); $tree->doSomething(); MyNode...

XmlSerializer changes in .NET 3.5 SP1

I've seen quite a few posts on changes in .NET 3.5 SP1, but stumbled into one that I've yet to see documentation for yesterday. I had code working just fine on my machine, from VS, msbuild command line, everything, but it failed on the build server (running .NET 3.5 RTM). [XmlRoot("foo")] public class Foo { static void Main() {...

XML serialization in Java?

Is there a (preferably free) Java analogue of .NET's XML serialization? ...

What XML books do you recommend?

XML is everywhere - I am looking for a book that would summarize some key aspects of practical use of XML with possible problems and solutions not a "XML bible" thing. Thanks for feedback in advance! ...

Equivalent to StAX for C

I've used the StAX API in Java quite a bit, and find it quite a clean way of dealing with XML files. Is there any equivalent library I could use for performing similar processing in C? ...

Add XML Comments to class properties generated by the LINQ to SQL designer

I used the LINQ to SQL designer in Visual Studio to create an object model of a database. Now, I want to add XML comments to each generated property but I can't figure out how to do it without erasing the properties the next time the dbml file is refreshed. How can this be done? ...

InfoPath 2003 and the xs:any type

I am implementing exception handling for our BizTalk services, and have run into a fairly major stumbling block. In order to make the exception processing as generic as possible, and therefore to allow us to use it for any BizTalk application, our XML error schema includes an xs:any node, into which we can place a variety of data, depen...

Displaying XML data in a Winforms control

I would like to display details of an xml error log to a user in a winforms application and am looking for the best control to do the job. The error data contains all of the sever variables at the time that the error occurred. These have been formatted into an XML document that looks something to the effect of: <error> <serverVaria...

XML in C# - Read from Resources, Manipulate and Display.

Hi Everyone, I'd like to do the following and can't find an elegant way: 1) Read an XML template into a System.Xml.XmlDocument 2) Populate it with data from my UI 3) Transform it with an XSLT I've written 4) Apply a CSS Stylesheet 5) Render it to a WebBrowser control I'm currently reading it from a file on disk, populating it, then s...

How do I change XML indentation in IntelliJ IDEA?

By default IntelliJ IDEA 7.0.4 seems to use 4 spaces for indentation in XML files. The project I'm working on uses 2 spaces as indentation in all it's XML. Is there a way to configure the indentation in IntelliJ's editor? ...

C++: How to extract a string from rapidxml

In my C++ program I want to parse a small piece of XML, insert some nodes, then extract the new XML (preferably as a std::string) RapidXML (http://rapidxml.sourceforge.net/) has been recommended to me, but I can't see how to retrieve the XML back as a text string. (I could iterate over the nodes and attributes and build it myself, but su...