Quantcast
Channel: Adobe Community : All Content - ColdFusion
Viewing all articles
Browse latest Browse all 5979

How to handle NULL or blank XML fields

$
0
0

I am parsing an xml file and turning it into a query object. Everything good until I get a NULL or misssing value in my XML file and then I start getting error messages like

The value '' cannot be converted to a number.

 

 

So how can I check for these missing or NULL values in the XML and then set them to a value  want so they dont keep appearing as ''?

 

Here is my code: It runs great until i hit a missing value

 

<cfset mydoc = XmlParse(myxml)>

 

<!--- get an array of employees --->

<cfset emp = mydoc.ROWSET.XmlChildren>

<cfset size = ArrayLen(emp)>

 

  <cfset orderquery = QueryNew("FIRST_NAME, LAST_NAME,FILE_NUMBER,JOB_TITLE_DESCRIPTION") >

<cfset temp = QueryAddRow(orderquery, #size#)>

<cfloop index="i" from = "1" to = "#size#">

  <cfset temp = QuerySetCell(orderquery, "FIRST_NAME",

        #mydoc.rowset.ROW[i].FIRST_NAME.XmlText#, #i#)>

  <cfset temp = QuerySetCell(orderquery, "LAST_NAME",

        #mydoc.rowset.ROW[i].LAST_NAME.XmlText#, #i#)>

  <cfset temp = QuerySetCell(orderquery, "FILE_NUMBER",

        #mydoc.rowset.ROW[i].FILE_NUMBER.XmlText#, #i#)>

  <cfset temp = QuerySetCell(orderquery, "JOB_TITLE_DESCRIPTION",

        #mydoc.rowset.ROW[i].JOB_TITLE_DESCRIPTION.XmlText#, #i#)>

 

</cfloop>


Viewing all articles
Browse latest Browse all 5979

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>