cfxml and empty tags
Is there a way to eliminate tags from the xml document if they are empty?
So <myTag></myTag> would not exist in the xml document. But if there is a value, <myTag>xxx</MyTag> would display.
Thanks!
-Robert
Is there a way to eliminate tags from the xml document if they are empty?
So <myTag></myTag> would not exist in the xml document. But if there is a value, <myTag>xxx</MyTag> would display.
Thanks!
-Robert
I haven't investigated your regex suggestion yet though I'm sure that would be the way to go.
I decided to do just what you were saying however. Don't generate the tag at all rather than strip empty ones.
Is there a better way to do this than what I was thinking...
<cfif getValues.value1 is not "">
<firstTag>#value1#</firstTag>
</cfif>
That seems cumbersome and inefficient if the xml doc is more than a few tags.
<cfif getValues.value1 is not ""> <firstTag>#value1#</firstTag> </cfif>
That seems cumbersome and inefficient if the xml doc is more than a few tags.
Well it's a strange requirement, so probably calls for some cumbersome code :-)
However I always try to make my conditionals sound "positive":
<cfif len(getValues.value1)>
<firstTag>#value1#</firstTag>
</cfif>
I guess if you have heaps and heaps of these, then perhaps sticking the blank ones in and then using a regex to get rid of all of them in one hit might be an option.
Without knowing the data and the XML schema, it's hard to give a well-informed answer though, really.
--
Adam
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.