How do I check if xml element exist and has a value and starts with CONF if exists RRS feed

  • Question

  • I need help to check xml element for several conditions in VB.NET code.
    1. If the SecurityGroup element doesn’t exist: set to IsConfidential to ‘false’
    2. If the SecurityGroup element exists: set to IsConfidential to ‘true’ when @Word starts with CONF
    3. Otherwise, set IsConfidential to ‘false’

    How do I do this?

    I am having trouble with if statements. I am able to check if the element SecurityGroup does not exist and sets the IsConfidential to False.
    I am not able to do numbers 2 and 3

    Here is XML Element

    <SecurityGroup Word="CONFGUA">Conf-Guardianship</SecurityGroup>

    VB.NET code

    Dim objInsertUpdateCase As MMGService.InsertUpdateCase = New MMGService.InsertUpdateCase
    If aobjXmlInputDoc.DocumentElement.SelectSingleNode("Case/SecurityGroup") Is Nothing Then
       objInsertUpdateCase.IsConfidential = False
    ElseIf Not aobjXmlInputDoc.DocumentElement.SelectSingleNode("Case/SecurityGroup/@Word").InnerText.StartsWith("CONF") Then 'CONF' Is Nothing Then
        objInsertUpdateCase.IsConfidential = True
       objInsertUpdateCase.IsConfidential = False
    End If

    Monday, July 22, 2019 5:01 PM

All replies