Test for Child Node Attributes RRS feed

  • Question

  • User812527939 posted

    I currently have this XML.

    <response success="true" error="">
        <PropertySet Name="IX_DOCUMENT" Caption="Document Additional Meta Data" AppliesToDocuments="TRUE" AppliesToFolders="FALSE" AppliesToUsers="FALSE" SystemUseOnly="FALSE">
            <DomainRestrictions Global="TRUE"/>
                <field FieldName="BARCODE" Caption="Barcode" DataType="CHAR" DataLength="50" Required="FALSE" ControlSize="50" ControlOrder="1" ControlType="TEXT BOX"/>
                <field FieldName="BOX_NUMBER" Caption="Box Number" DataType="CHAR" DataLength="16" Required="FALSE" ControlSize="16" ControlOrder="2" ControlType="TEXT BOX"/>

    This is returned to me as XmlElement. I am having trouble writing some code that will check the grandchildren 'fields' for the 'FieldName' attribute. I need to return true if it can find a field with FieldName as BARCODE and a FieldName as BOX_NUMBER. Not sure if this helps at all but the code that I use to retrieve this is;

    XmlElement XmlResponse = (XmlElement)IR_OBJ.GetPropertySetDefinition(ticket, "IX_DOCUMENT");

    Any help is appreciated.

    EDIT: Put XML in Code

    Tuesday, October 27, 2015 9:41 PM


  • User-271186128 posted

    Hi JohZant,

    I suggest you could try to use the following code to get the field node and check the attribute.

                XmlDocument xml = new XmlDocument();
                StringBuilder sb = new StringBuilder();
                XmlNodeList list = xml.SelectNodes("/response/PropertySet/Fields/field");
                bool flagFieldName1 = false; //check whether the fieldName is BARCODE
                bool flagFieldName2 = false;  //check whether the fieldName is BOX_NUMBER
                foreach (XmlNode node in list)
                    if (node.Attributes["FieldName"].Value == "BARCODE")
                        flagFieldName1 = true;
                    if (node.Attributes["FieldName"].Value == "BOX_NUMBER")
                        flagFieldName2 = true;
                if (flagFieldName1 == true && flagFieldName2 == true)

    Best regards,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 28, 2015 2:20 AM