Skip to main content
Participant
September 18, 2006
Question

Error handling an empty structure

  • September 18, 2006
  • 3 replies
  • 279 views
I have a web app that queries a database and returns the results in XML. I used SOXML - XML2CF to convert the XML to a CF Structure. Everything works great if there are hits and the XML contains results. If there are no results, the app fails. What I need is to check the structure for the existance of data before trying to display the results.

Here's what I have...

<cf_soxml action="XML2CF" input="#CFHTTP.FileContent#" output="jobPostings">
<cfset availJobs = jobPostings.root["Job"]>

If there are no results to display, I get this...

The object JOB is not present in the scope named JOBPOSTINGS.ROOT.

Anyone know how I can search the structure for the existance of ROOT.JOB so I can display a message if there are no results?

Thanks,
Joe
    This topic has been closed for replies.

    3 replies

    Inspiring
    September 18, 2006
    Better yet, query.recordcount before attempting to build the structure.
    jstoppieAuthor
    Participant
    September 18, 2006
    Thanks Paul!
    Inspiring
    September 18, 2006
    jstoppie wrote:
    > Anyone know how I can search the structure for the existance of ROOT.JOB so I
    > can display a message if there are no results?

    structKeyExists()