Problems with System.Xml

  • Thread starter Thread starter Giulio Petrucci
  • Start date Start date
G

Giulio Petrucci

Hi there,

I have this snippet:

using System.Xml;
....

XmlDocument doc = ...;
XmlNode foo = doc.CreateElement("foo");
foo.Attributes.Appen(doc.CreateAttribute("id", "23"));

my 'foo' tag looks like this:

<foo d2p1:id="" d2p1="23"/>

My questions are:
1. Why? ;-)
2. How can I get rid of the d2p stuff and have just <foo id="23/>?

Thanks in advance,
Giulio
--
 
Hi there,

I have this snippet:

using System.Xml;
...

XmlDocument doc = ...;
XmlNode foo = doc.CreateElement("foo");
foo.Attributes.Appen(doc.CreateAttribute("id", "23"));

my 'foo' tag looks like this:

<foo d2p1:id="" d2p1="23"/>

My questions are:
1. Why? ;-)
2. How can I get rid of the d2p stuff and have just <foo id="23/>?

Thanks in advance,
Giulio
--

XmlDocument doc = new XmlDocument();
XmlElement foo = doc.CreateElement("foo");
foo.SetAttribute("id", "23");
doc.AppendChild(foo);
 
Hi Raghupathi,

Raghupathi said:
XmlDocument doc = new XmlDocument();
XmlElement foo = doc.CreateElement("foo");
foo.SetAttribute("id", "23");
doc.AppendChild(foo);

Terrific. This fixes my problem.
Anyway, my first question still remains: why? ;-)

Ciao,
Giulio - Italy
--
 
Back
Top