Click here to Skip to main content
15,889,853 members
Articles / Programming Languages / XML
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
27 Nov 2009CPOL 30.6K   3  
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)


Written By
Database Developer Freelancer
Ukraine Ukraine
MS SQL Server Database Developer with 7+ years experience

Technologies/languages: Business Intelligence, SQL, MDX, VBA, SQL Server, Analysis Services (SSAS), Reporting services (SSRS), Integration Services (SSIS), DataWarehouse.
Also: economic background.

Feel free to contact me for rates and details.

Comments and Discussions

 
-- There are no messages in this forum --