未命名的命名空间添加到xmlnode
问题描述:
我想添加一个未命名的命名空间到我的根xmlnode。我该怎么做呢?未命名的命名空间添加到xmlnode
错误消息---
为元素或属性的本地名称不能为空或空字符串。
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ShipmentReceiptNotification0Node = xmlDoc.CreateElement("ShipmentReceiptNotification", "", "namespacename");
ShipmentReceiptNotification0Node.InnerText = String.Empty;
xmlDoc.AppendChild(ShipmentReceiptNotification0Node);
答
使用CreateElement其他2参数覆盖。
var node = xmlDoc.CreateElement("ShipmentReceiptNotification", "namespacename");
答
试着改变你这样的代码:
XmlNode ShipmentReceiptNotification0Node = xmlDoc.CreateElement("ShipmentReceiptNotification", "namespacename");