As Usman recommended, you can use LINQ, but another popular option is to use XPath. You can use XPath to select the appropriate elements using a class XDocumentor an older class XmlDocument.
Here you can do it with XPath via the class XDocument:
Dim doc As New XDocument()
doc.Load(filePath)
Dim name As String = doc.XPathSelectElement("/Categories/category[@name='a']/SubCategoryName").Value
And here is how you do it with XPath through the class XmlDocument:
Dim doc As New XmlDocument()
doc.Load(filePath)
Dim name As String = doc.SelectSingleNode("/Categories/category[@name='a']/SubCategoryName").InnerText
Here's the meaning of parts of XPath:
/Categories- The slash at the beginning indicates that it is looking at the root of the XML document. After the slash follows the name of the subelement that we are looking for in the root./category - , /Categories.[@name='a'] - , If. @, ( )./SubCategoryName - , category, .
XPath . XPath - , XML, XSLT, . , XML node . LINQ , Microsoft, LINQ , , XPath .
XPath //category[@name='a']/SubCategoryName. , .