I have an XML file, which is being loaded into an XmlDocument object in my code. It contains some nodes which have self closing tags. How do I access and change the text contained within these ? I.E. I can access the text of non self closing tags using node.InnerText (<tag>value</tag>), but that does not work for self closing tags (<tag valueName = value/>).
CodePudding user response:
Being a beginner at C#, I was unaware of the node.Attributes property. I can simply access valName using:
string valName = node.Attributes["valName"].Value;
This will assign val to valName.
