I
Ilyas
Hi all
I have the following code:
Namespace ns = "http://www.abc.com";
XDocument xDoc = new XDocument(
new XElement(ns + "root",
new XElement("person",
new XAttribute("id", 1),
new XElement("forename", "jack"),
new XElement("age", 35)),
new XElement("person",
new XAttribute("id", 2),
new XElement("forename", "bob"),
new XElement("age", 2)
)));
This is the xml written if I do Console.WriteLine(xDoc):
<root xmlns="http://www.abc.com">
<person id="1" xmlns="">
<forename>jack</forename>
<age>35</age>
</person>
<person id="2" xmlns="">
<forename>bob</forename>
<age>2</age>
</person>
</root>
However why do both person elements have a blank for xmlns. I would
have though that would have not been there....can anyone explain. How
do I get rid of the xmlns='' ?
What I want is if no namespace is specified then my xml elements
should be in the default namespace (http://www.abc.com) - how can
Imodify the above code so I dont end up with xmlns='' in the person
tags...?
Thanks
I have the following code:
Namespace ns = "http://www.abc.com";
XDocument xDoc = new XDocument(
new XElement(ns + "root",
new XElement("person",
new XAttribute("id", 1),
new XElement("forename", "jack"),
new XElement("age", 35)),
new XElement("person",
new XAttribute("id", 2),
new XElement("forename", "bob"),
new XElement("age", 2)
)));
This is the xml written if I do Console.WriteLine(xDoc):
<root xmlns="http://www.abc.com">
<person id="1" xmlns="">
<forename>jack</forename>
<age>35</age>
</person>
<person id="2" xmlns="">
<forename>bob</forename>
<age>2</age>
</person>
</root>
However why do both person elements have a blank for xmlns. I would
have though that would have not been there....can anyone explain. How
do I get rid of the xmlns='' ?
What I want is if no namespace is specified then my xml elements
should be in the default namespace (http://www.abc.com) - how can
Imodify the above code so I dont end up with xmlns='' in the person
tags...?
Thanks