0

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);

2 Answers 2

1

Use the other 2 argument override for CreateElement.

var node = xmlDoc.CreateElement("ShipmentReceiptNotification", "namespacename");
Sign up to request clarification or add additional context in comments.

Comments

0

try changing your code like this:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.