Charles Morrison
Charles Morrison

Reputation: 428

unnamed namespace adding to xmlnode

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

Answers (2)

yaens
yaens

Reputation: 167

try changing your code like this:

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

Upvotes: 0

Alexei Levenkov
Alexei Levenkov

Reputation: 100527

Use the other 2 argument override for CreateElement.

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

Upvotes: 1

Related Questions