Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / XML

The prefix '' cannot be redefined from '' to 'namespaceURI' within the same start element tag.

0.00/5 (No votes)
27 Nov 2009CPOL 31.2K  
xmlns is special attribute. It determines namespace of current element and its children all as well. You do not have to add it to XmlDocument (XmlElement) explicitly. Use method of XmlDocument:public virtual XmlElement CreateElement( string prefix, string localName, string...

xmlns is special attribute. It determines namespace of current element and its children all as well. You do not have to add it to XmlDocument (XmlElement) explicitly. Use method of XmlDocument:



C#
public virtual XmlElement CreateElement(
    string prefix,
    string localName,
    string namespaceURI
)

Details on MSDN.



If you want you can create special method to deliver yourself from constant namespaceURI writing, something likes as following:



C#
protected XmlElement CreateElement(string nodeName)
{
	return xmlaScript.CreateElement("", nodeName, asNamespaceURI);
}

where xmlaScript is XmlDocument object and asNamespaceURI is namespace URI.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)