'How to get the value of a node in a list of XElements

I need the string "duplicate-result" but I keep getting a null reference error on the line that reads that element. I have the result name, the template and the name, but I can't get the reason. In the current version subErr throws a "System.NullReferenceException." I tried getting the value of the node but that was an invalid cast. Below is a section of the repeated XML and my little method to read the information. I have looked here and there are no similar examples. I cannot change the XML output.

       <result succeed="No" template="text" name="Frame Number" testid="123456">
            <errors>
                <error name="duplicate-result"/>
            </errors>
        </result>


    For Each err As XElement In errList
        resultName = err.Attribute("name").Value
        resultTemplate = err.Attribute("template").Value
        errString = "Upload Error: " & resultTemplate & ", " & resultName & " failed. "
        For Each subErr As XElement In err.Elements("errors")
            errString &= subErr.Element("name").Value & ","
        Next
        errString = Left(errString, Len(errString) - 1)
    Next


Solution 1:[1]

It's an attribute, not an Element. try in the for loop.

errString &= subErr.Attribute("name").Value & ","

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 CooPzZ