CRM2016
I'm trying to read an XML file, which may or may not contain different tags
In this case I'm trying to return a Boolean if the tag <AgreementOfFileTotals> exists
My code return false on evry file regardless of if it contains <AgreementOfFileTotals> or not
My code
Dim FileType1 AsBoolean = False
Using reader AsXmlReader = XmlReader.Create(NewStringReader(XMLFile))
While reader.Read()
If reader.NodeType = XmlNodeType.Element AndAlso reader.Name = "AgreementOfFileTotals"Then
FileType1 = False'Does NOT contain <AgreementOfFileTotals>
Else
FileType1 = True' Contains <AgreementOfFileTotals>
EndIf
EndWhile
EndUsing
XML File Structure
<BACSDocument>
<Data>
<InputReport>
<Header>
<ProducedOn />
<ProcessingDate/>
</Header>
<Submission>
<SubmissionInformation />
<UserFile >
<InputUserFile>
<UserFileInformation />
<DaySection >
<DaySectionRecord >
<Credit >
<Contra />
</Credit>
<Debit >
<Contra />
</Debit>
</DaySectionRecord>
<Totals>
<Credit >
<Contra />
</Credit>
<Debit >
<Contra />
</Debit>
</Totals>
</DaySection>
<InputReportSummary>
<AccountTotals>
<AccountTotal >
<CreditEntry>
<AcceptedRecords />
<RejectedRecords />
<TotalsRecords />
</CreditEntry>
<DebitEntry>
<AcceptedRecords />
<RejectedRecords />
<TotalsRecords />
</DebitEntry>
<CreditContraEntry>
<AcceptedRecords />
<RejectedRecords />
<TotalsRecords />
</CreditContraEntry>
<DebitContraEntry>
<AcceptedRecords />
<RejectedRecords />
<TotalsRecords />
</DebitContraEntry>
</AccountTotal>
</AccountTotals>
<AgreementOfFileTotals>
<CreditEntry>
<AcceptedRecords />
<RejectedRecords />
<UserTrailerTotals />
<AdjustmentRecords />
</CreditEntry>
<DebitEntry>
<AcceptedRecords />
<RejectedRecords />
<UserTrailerTotals />
<AdjustmentRecords />
</DebitEntry>
</AgreementOfFileTotals>
</InputReportSummary>
</InputUserFile>
</UserFile>
</Submission>
</InputReport>
</Data>
<SignatureMethod></SignatureMethod>
</BACSDocument>