Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: default namespace xmlns

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 8/12/2008 2:50:00 PM

byggemandBob wrote:
> Hi I written some x++ code to export a xml file but I bumped into a small 
> problem
> my root node have 3 attributes and I add them like this.
> 
>     XMLDocOR = new XMLDocument();
> 
>     interchange = XMLDocOR.createElement("Interchange");
>     XMLDocOR.appendChild(Interchange);
>         att1 = XMLDocOR.createAttribute("xmlns");
>         att1.nodeValue("http://...Omitted...");

If you want to create an element in a certain namespace then you need to 
use a namespace aware creation method. I am not sure which DOM 
implementation you use with x++, if that is MSXML then you need to use
   interchange = XMLDocOR.createNode(1, "Interchange", 
"http://example.com/foo")
where http://example.com/foo is the namespace URI.
You need to take that approach for all elements to be created in that 
namespace so if you want to create any child elements then you need to 
use the same approach e.g.
   bar = XMLDocOR.createNode(1, "bar", "http://example.com/foo")
   interchange.appendChild(bar)

If you are using the .NET DOM implementation then you don't need to use 
createNode, instead then there is a namespace aware overload of 
createElement e.g.
   interchange = XMLDocOR.createElement("Interchange", 
"http://example.com/foo")
   bar = XMLDocOR.createElement("bar", "http://example.com/foo")
   interchange.appendChild(bar)

There is no need to create xmlns attribute.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent