I have an XDocument object where I am trying to get the direct parent element based on a child element's value.
Getting the child element's value has been no issue, but I am struggling with finding the correct way to get only the parent element. Having not worked with XML much, I have a suspicion that the solution is simple and I am overthinking it.
Essentially, based on the below XML, if <Active>true</Active> then I want the direct parent element (i.e. <AlertNotification>) and no other elements.
Thank you in advance.
An example of the XML
<?xml version="1.0" encoding="utf-16"?>
<Policies xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLschema">
<PolicyID>1</PolicyID>
<EmailNotification>
<Active>false</Active>
</EmailNotification>
<AlertNotification>
<Active>true</Active>
</AlertNotification>
<AlarmEnabled>
<Active>false</Active>
</AlarmEnabled>
</Policies>
AlertNotificationdoes not contain any data - Sergey Berezovskiy