2013-03-07 60 views
0

我想添加一個未命名的命名空間到我的根xmlnode。我該怎麼做呢?未命名的命名空間添加到xmlnode

錯誤消息---

爲元素或屬性的本地名稱不能爲空或空字符串。

 System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); 

     XmlNode ShipmentReceiptNotification0Node = xmlDoc.CreateElement("ShipmentReceiptNotification", "", "namespacename"); 

     ShipmentReceiptNotification0Node.InnerText = String.Empty; 
     xmlDoc.AppendChild(ShipmentReceiptNotification0Node); 

回答

1

使用CreateElement其他2參數覆蓋。

var node = xmlDoc.CreateElement("ShipmentReceiptNotification", "namespacename"); 
0

試着改變你這樣的代碼:

XmlNode ShipmentReceiptNotification0Node = xmlDoc.CreateElement("ShipmentReceiptNotification", "namespacename");