xml

How to prevent blank xmlns attributes in output from .NET's XmlDocument?

When generating XML from XmlDocument in .NET, a blank xmlns attribute appears the first time an element without an associated namespace is inserted; how can this be prevented? Example: XmlDocument xml = new XmlDocument(); xml.AppendChild(xml.CreateElement("root", "whatever:name-space-1.0")); xml.DocumentElement.AppendChild(xml.Crea...

Does XSLT have a Split() function?

I have a string in a node and I'd like to split the string on '?' and return the last item in the array. For example, in the block below: <a> <xsl:attribute name="href"> /newpage.aspx?<xsl:value-of select="someNode"/> </xsl:attribute> Link text </a> I'd like to split the someNode value. Edit: Here's the VB.Net t...

PHP Object as XML Document

What is the best way to take a given PHP object and serialize it as XML? I am looking at simple_xml and I have used it to parse XML into objects, but it isn't clear to me how it works the other way around. ...

What is the best way to parse a web page in Ruby?

I have been looking at XML and HTML libraries on rubyforge for a simple way to pull data out of a web page. For example if I want to parse a user page on stackoverflow how can I get the data into a usable format? Say I want to parse my own user page for my current reputation score and badge listing. I tried to convert the source retri...

Tool to convert csv/excel to xml

Hi, As title but would like the flexibility to specify how the output xml file will look like. Any free tool available on windows platform that I can use to achieve that? Thanks ...

Pure Python XSLT library

Is there an XSLT library that is pure Python? Installing libxml2+libxslt or any similar C libraries is a problem on some of the platforms I need to support. I really only need basic XSLT support, and speed is not a major issue. ...

What are the merits of CSV and/or JSON and/or XML and/or ??? output in a REST API?

We're currently trying to plan a new developer API for our application and debating the various data formats we should use for interchange. We're also going to be using this API for our official desktop application so we're going to have a working implementation before it goes public. There's a fairly intense discussion going on about ...

how to pretty print xml from Java

I have a Java String that contains XML, with no line feeds and indentations. I would like to turn in into a String with nicely formatted XML. How do I do this? String unformattedXml = "<tag><nested>hello</nested></tag>"; String formattedXml = new [UnknownClass]().format(unformattedXml); Note: My input is a String. My output is a Strin...

Writing XML files using XmlTextWriter with ISO-8859-1 encoding (C#)

I'm having a problem writing Norwegian characters into an XML file using C#. I have a string variable containing some Norwegian text (with letters like æøå). I'm writing the XML using an XmlTextWriter, writing the contents to a MemoryStream like this: MemoryStream stream = new MemoryStream(); XmlTextWriter xmlTextWriter = new XmlTextW...

Namespace scope in SOAP / XML

Is this valid SOAP / XML? <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <soap:Body> <CreateRoute xmlns="urn:Routs"> <aRoute> <name>ToTheTop</...

When writing XML, is it better to hand write it, or to use a generator such as simpleXML in PHP?

I have normally hand written xml like this: <tag><?= $value ?></tag> Having found tools such as simpleXML, should I be using those instead? What's the advantage of doing it using a tool like that? ...

RightNow CRM XML API - Anyone familiar with it?

I need to create a user control in either vb.net or c# to search a RightNow CRM database. I have the documentation on their XML API, but I'm not sure how to post to their parser and then catch the return data and display it on the page. Any sample code would be greatly appreciated! Link to API: http://community.rightnow.com/customer/do...

What are the advantages and disadvantages of using XML schemas?

We are utilizing the XML data type in Microsoft SQL Server 2005 for a project. Some members of the team and I feel that we should also use XSDs while members of the other camp feel that we should keep the XMLs ad hoc and not treat them as "types". The XMLs are an effort to bring structure and centrality to a number of text configuration...

Querying XML like SQL?

Is there any framework for querying XML SQL Syntax, I seriously tire of iterating through node lists. Or is this just wishful thinking (if not idiotic) and certainly not possible since XML isn't a relational database? ...

xsl scope help

I have a xsl file that is grabbing variables from xml and they seem to not be able to see each other. I know it is a scope issue, I just do not know what I am doing wrong. <xsl:template match="one"> <xsl:variable name="varOne" select="@count" /> </xsl:template> <xsl:template match="two"> <xsl:if test="$varOne = 'Y'"> <xsl:value-...

Storing Relational Data in XML

I'm wondering what the best practices are for storing a relational data structure in XML. Particulary, I am wondering about best practices for enforcing node order. For example, say I have three objects: School, Course, and Student, which are defined as follows: class School { List<Course> Courses; List<Student> Students; } cla...

Is there an issue sending XML via WCF?

Suppose you have an XElement or an XmlElment or even a string containing xml that you want to send via WCF. Are there any special precautions you have to take? The question just came up, what happens when, within the xml message, you transmit an xml document declaration (<?xml version=’1.0’ ?>), which may happen if serializing an XmlDo...

Best way to compare 2 XML documents in Java

I'm trying to write an automated test of an application that basically translates a custom message format into an XML message and sends it out the other end. I've got a good set of input/output message pairs so all I need to do is send the input messages in and listen for the XML message to come out the other end. When it comes time to...

Can XPath do a foreign key lookup across two subtrees of an XML?

Say I have the following XML... <root> <base> <tent key="1" color="red"/> <tent key="2" color="yellow"/> <tent key="3" color="blue"/> </base> <bucket> <tent key="1"/> <tent key="3"/> </bucket> </root> ...what would the XPath be that returns that the "bucket" contains "red" and "blue"? ...

Create xml-stylesheet PI with Rails XMLBuilder

I want to attach an xslt stylesheet to an XML document that I build with XMLBuilder. This is done with a Processing Instruction that looks like <?xml-stylesheet type='text/xsl' href='/stylesheets/style.xslt' ?> Normally, I'd use the instruct! method, but :xml-stylesheet is not a valid Ruby symbol. XMLBuilder has a solution for this ...