We are having some problems with parsing xml files. Some of entities don't exist for every record and this is the only way we came up with to keep the program from erroring out. Does anyone have any better suggestions for writing this code and account for those entities that don't exist in every record. Thanks in advance. Here's what we coded:
bPubDateFailed = .f.
ON ERROR bPubDateFailed=.t.
oPubDate = oJournalIssue.getElementsByTagName("PubDate").item(0)
ON ERROR
IF bPubDateFailed <> .t. THEN
ON ERROR strJournalIssuePubDateYear = ""
strJournalIssuePubDateYear =
oPubDate.getElementsByTagName("Year").item(0).text
ON ERROR
ON ERROR strJournalIssuePubDateMonth = ""
strJournalIssuePubDateMonth =
oPubDate.getElementsByTagName("Month").item(0).text
ON ERROR
ELSE
strJournalIssuePubDateYear = ""
strJournalIssuePubDateMonth = ""
ENDIF
bPubDateFailed = .f.
ON ERROR bPubDateFailed=.t.
oPubDate = oJournalIssue.getElementsByTagName("PubDate").item(0)
ON ERROR
IF bPubDateFailed <> .t. THEN
ON ERROR strJournalIssuePubDateYear = ""
strJournalIssuePubDateYear =
oPubDate.getElementsByTagName("Year").item(0).text
ON ERROR
ON ERROR strJournalIssuePubDateMonth = ""
strJournalIssuePubDateMonth =
oPubDate.getElementsByTagName("Month").item(0).text
ON ERROR
ELSE
strJournalIssuePubDateYear = ""
strJournalIssuePubDateMonth = ""
ENDIF