Reputation: 428
I want to add an unnamed namespace to my root xmlnode. how do I do this?
error message---
The local name for elements or attributes cannot be null or an empty string.
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ShipmentReceiptNotification0Node = xmlDoc.CreateElement("ShipmentReceiptNotification", "", "namespacename");
ShipmentReceiptNotification0Node.InnerText = String.Empty;
xmlDoc.AppendChild(ShipmentReceiptNotification0Node);
Upvotes: 0
Views: 1143
Reputation: 167
try changing your code like this:
XmlNode ShipmentReceiptNotification0Node = xmlDoc.CreateElement("ShipmentReceiptNotification", "namespacename");
Upvotes: 0
Reputation: 100527
Use the other 2 argument override for CreateElement.
var node = xmlDoc.CreateElement("ShipmentReceiptNotification", "namespacename");
Upvotes: 1