XMLDocument.CreateElement always adds namespace?

I just noticed that any time I use XMLDocumentCreateElement, it adds a namespace to the XML. According to the documentation under “XMLDocument.CreateElement”, there are two forms of this method - one that adds a namespace and one that doesn’t. However, I find the namespace is always added to the xml, even when I pass “” as the namespace. (Neither of the examples in the docs include namespaces.)

Here’s an example of what I expected Xojo to write (and was written by older versions of Xojo/RealStudio):

S4-19 10

This is what it’s writing using Xojo 2014 R2:

S4-19 10

Older versions of Xojo didn’t do this, is this new behavior? A bug? is there a way to avoid having the URI added?

The .xml I’m receiving from another app doesn’t have URI’s in it, and I’d rather use the same overall format as that app does if possible. Or is omitting the URI a big mistake?

The sample code on the CreateElement page does not add a namespace. What does your code look like?

This is the code, in both Xojo and RealStudio:


It produces this:

No. 1 ELEC

Instead of what it used to produce:

No. 1 ELEC

I’ve just tried this code:

[code] Dim xml As New XmlDocument
Dim root As XmlNode
root = xml.AppendChild(xml.CreateElement(“League”))

Dim teamNode As XmlNode
Dim playerNode As XmlNode

// Create 1st team and its players
teamNode = root.AppendChild(xml.CreateElement(“Team”))
teamNode.SetAttribute(“name”, “Seagulls”)
and it produces the following XML in 2014r2:

<League><Team name="Seagulls"></Team></League>

So unless you’re calling the version of CreateElement which takes a namespace, I can’t imagine how you’re getting this result.

What is the data type of AttribNode ?


Oddly enough, the namespace is only added to the first node created in each pass through the .xml file. If I open the .xml file and read in it’s contents, then make multiple changes to it, only the first node added or modified gets the namespace - the subsequent ones are not.

The way the code flow works, the file is opened and read for each change in field data, so the result is every field winds up with a namespace. I can’t generally do multiple changes to the file in one operation because my app can lose focus at any moment and that’s when the data in the .xml file is read and processed by someone else’s application.

This is part of a much larger project that merges changes made by my app into an existing .xml file. I will have to separate it out of the existing code and create a sample application that demonstrates the problem, as it involves reading the file, searching for relevant nodes, then modifying or creating new nodes and finally saving the .xml back to the file.