SetAttributeNode method only for root?

  • Thread starter Thread starter Jeroen Ceuppens
  • Start date Start date
J

Jeroen Ceuppens

I want to add a atribute for a child node, but it isn't possible, only the
SetAttributeNode method is for the root? Does anybody know a solution to add
a attribute to a child or other node than root?

<notrootnode id="65">

Greetz
JJC
 
SetAttribute(string, string) works on any node which is an element. Of
course you will have to cast it to XmlElement
(node as XmlElement).SetAttribute("id", "65");
CType(node, XmlElement).SetAttribute("id", "65")

Might also want to make sure that
node.NodeType = XmlNodeType.Element
 
XmlNode is a base type for all types of nodes: XmlElement, XmlAttribute,
XmlProcessingInstruction etc.
XmlNode is a generic node in the xml document. Element is a node that can
have attributes
 
Back
Top