all groups > dotnet xml > december 2004 >
You're in the

dotnet xml

group:

XmlAttributeCollection.SetNamedItem problem


XmlAttributeCollection.SetNamedItem problem Riko Eksteen
12/14/2004 1:11:42 PM
dotnet xml:
When I try to call SteNamedItem(XmlNode) on an AttributeCollection where a
node with the same name already exists, I get a NullReferenceException
("object reference not set to an instance of an object"). This goes against
the described behaviour of the method, which is supposed to replace the
attribute node with the new one, isn't it?

Here is the code:
XmlAttribute valueAttr =
targetNode.OwnerDocument.CreateAttribute("Value");

valueAttr.Value = value;

targetNode.Attributes.SetNamedItem(valueAttr);

Re: XmlAttributeCollection.SetNamedItem problem Oleg Tkachenko [MVP]
12/14/2004 4:00:09 PM
[quoted text, click to view]

I can't reproduce the problem. Provide more info please.

--
Oleg Tkachenko [XML MVP]
AddThis Social Bookmark Button