Page 1 of 1

checking if optional xml element is present

Posted: Thu Apr 25, 2013 7:11 am
by Jozef Balga
Hello!

I have the following xml element defined in the schema:

Code: Select all

<xs:element minOccurs="0" maxOccurs="1" name="specificMetadata">
              <xs:complexType>
                <xs:sequence minOccurs="0" maxOccurs="1">
                  <xs:element minOccurs="0" maxOccurs="1" name="customerNumber" type="xs:string" />
                  <xs:element minOccurs="0" maxOccurs="1" name="accountNumber" type="xs:string" />
				  <xs:element minOccurs="0" maxOccurs="1" name="customerTextual" type="xs:string" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>			
I have a problem identifying if the xml input data contains the optional element <accountNumber> or not. Unfortunately I do not have the xsd schema available when I register the dataset for the template - so only the xml is registered. I tried using the condition

Code: Select all

specificMetadata["accountNumber"] == DBNull.Value
but it does not work. Is there any other way to check if the optional element is present, or is it mandatory to register the xsd schema too?
Thank you for the reply.

Jozef

Re: checking if optional xml element is present

Posted: Thu Apr 25, 2013 12:27 pm
by Alex K.
Hello,

Yes. In this case you can register the xsd schema too.

Thank you.