0

I get an empty xmlns="" attribute in XElemenet in an XML tree. When I set its namespace to the document namespace, like this:

string xmlns="FreeForm/SchemaDescription"; XNamespace ana = xmlns; XElement interactiveRootTag = new XElement(ana + "InteractiveRootTag"); 

the empty xmlns="" is not exist any more, but all of the children of this XElement, get the empty xmlns="".

Any ideas?

1 Answer 1

1

You have to add the child element in this way:

string xmlns="FreeForm/SchemaDescription"; XNamespace ana = xmlns; XElement interactiveRootTag = new XElement(ana + "InteractiveRootTag"); interactiveRootTag.Add(new XElement(ana + "ChildElement", new XAttribute("attribute","AttributeValue"))); 

To get XML like this

<InteractiveRootTag xmlns="FreeForm/SchemaDescription"> <ChildElement attribute="AttributeValue" /> </InteractiveRootTag> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.