checking if optional xml element is present

Stimulsoft Reports.NET discussion
Post Reply
Jozef Balga
Posts: 56
Joined: Fri May 27, 2011 8:33 am
Location: Bratislava, Slovakia

checking if optional xml element is present

Post 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
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: checking if optional xml element is present

Post by Alex K. »

Hello,

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

Thank you.
Post Reply