xml

Removing nodes from an XmlDocument

The following code should find the appropriate project tag and remove it from the XmlDocument, however when I test it, it says: The node to be removed is not a child of this node. Does anyone know the proper way to do this? public void DeleteProject (string projectName) { string ccConfigPath = ConfigurationManager.AppSettings["Con...

How do you remove invalid hexadecimal characters from an XML-based data source prior to constructing an XmlReader or XPathDocument that uses the data?

Is there any easy/general way to clean an XML based data source prior to using it in an XmlReader so that I can gracefully consume XML data that is non-conformant to the hexadecimal character restrictions placed on XML? Note: The solution needs to handle XML data sources that use character encodings other than UTF-8, e.g. by specifyi...

XML Collection Best Practices

I'm creating an application that will store a hierarchical collection of items in an XML file and I'm wondering about the industry standard for storing collections in XML. Which of the following two formats is preferred? (If there is another option I'm not seeing, please advise.) Option A <School> <Student Name="Jack" /> <Stude...

Best method to parse various custom XML documents in Java

What is the best method to parse multiple, discrete, custom XML documents with Java? ...

Is it essential that I use libraries to manipulate xml?

I am using java back end for creating an xml string which is passed to the browser. Currently I am using simple string manipulation to produce this xml. Is it essential that I use some xml library in java to produce the xml string? I find the libraries very difficult to use compared to what I need. ...

Which Java DOM Wrapper is the Best or Most Popular?

I've used jdom in the past, and have looked briefly at XOM and DOM4j. Each seems to provide essentially the same thing, as they each provide a simplified wrapper over the (very obtuse) standard W3C DOM APIs. I know that JDOM went through some effort to develop a JSR and standardization process at one point, but as far as I know that ef...

Java configuration framework

I'm in the process of weeding out all hardcoded values in a java library and was wondering what framework would be the best (in terms of zero- or close-to-zero configuration) to handle run-time configuration? I would prefer xml-based config-files, but it's not essential. Please do only reply if you have practical experience with a fram...

Proper name space managment in .NET XmlWriter

I use .NET XML technologies quite extensively on my work. One of the things the I like very much is the XSLT engine, more precisely the extensibility of it. However there one little piece which keeps being a source of annoyance. Nothing major or something we can't live with but it is preventing us from producing the beautiful XML we woul...

XSL Dynamic Element Names

I want to transform an XML document. The source XML looks like this: <svc:ElementList> <svc:Element> <Year>2007</Year> </svc:Element> <svc:Element> <Year>2006</Year> </svc:Element> <svc:Element> <Year>2005</Year> </svc:Element> </svc:ElementList> I want to turn that into: <ElementList> ...

Generating an object model in Ruby from an XML DTD

I have an XML document with a DTD, and would love to be able to access the XML model, something like this: title = Thing.Items[0].Title Is there a way, in Ruby, to generate this kind of object model based on a DTD? Or am I stuck using REXML? Thanks! ...

Comparing two XML Schemas

Are there any tools to effectively compare two XML schema's? I have seen some generic XML diff tools, but I was wondering if there is anything that knows more about schemas. ...

XML => HTML with Hpricot and Rails

I've never worked with web services and rails, and obviously this is something I need to learn. I've chosen to use hpricot because it looks great. Anyway, _why's been nice enough to provide the following example on the hpricot website: #!ruby require 'hpricot' require 'open-uri' # load the RedHanded home page doc = Hpricot(open("ht...

PHP - Determine Parent Node Of DOMElement

I'm translating my C# code for YouTube video comments into PHP. In order to properly nest comment replies I need to re-arrange XML nodes. In PHP I'm using DOMDocument and DOMXPath which closely corresponds to C# XmlDocument. I've gotten pretty far in my translation but now I'm stuck on getting the parent node of a DOMElement. A DOMElemen...

Parsing XML using unix terminal

Sometimes I need to quickly extract some arbitrary data from XML files to put into a CSV format. What's your best practices for doing this in the Unix terminal? I would love some code examples, so for instance how can I get the following problem solved? Example XML input: <root> <myel name="Foo" /> <myel name="Bar" /> </root> My desi...

How do I create an xml document in python

It's my first time generating xml with python, and the python documentation, which is generally good, is really lacking for xml creation...here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document() node = doc.createElement('foo') node.innerText = 'bar' doc.appendChild(node) return doc if...

How do I select an XML-node based on its content?

How can I use XPath to select an XML-node based on it's content? If I e.g. have the following xml and I want to select the <author>-node that contains Ritchie to get the author's full name: <books> <book isbn='0131103628'> <title>The C Programming Language</title> <authors> <author>Ritchie, Dennis M.</author> ...

Should DOM splitText and normalise compose to give the identity?

I got embroiled in a discussion about DOM implementation quirks yesterday, with gave rise to an interesting question regarding Text.splitText and Element.normalise behaviours, and how they should behave. In DOM Level 1 Core, Text.splitText is defined as... Breaks this Text node into two Text nodes at the specified offset, keeping bo...

Parsing XML Elements & Attributes with Perl

So I wrote some perl that would parse results returned from the Amazon Web Services. I am using the XML::Simple package. For the most part, everything worked when I pulled out an element. However, the problem I ran into was when an element had an attribute as well. Then I get an error that the item is a Hash. Here's what I did if ...

How would you use Java to handle various XML documents?

I'm looking for the best method to parse various XML documents using a Java application. I'm currently doing this with SAX and a custom content handler and it works great - zippy and stable. I've decided to explore the option having the same program, that currently recieves a single format XML document, receive two additional XML docu...

Lightweight rich-text XML format?

I am writing a basic word processing application, and I am trying to settle on a native "internal" format, the one that my code parsers in order to render to the screen. I'd like this to be XML, so that I can, in the future, just write XSLT to convert it to ODF or XHTML or whatever. However, when searching for existing standards to use,...