'How to change value of XML Node with Self closing Tag using C#

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/>).



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eeshan