I'm having an issue where I assign a variable from...
# lucee
n
I'm having an issue where I assign a variable from an XML node. I can cfoutput the variable I only get the value which seems correct. If I use cfdump on the variable I only get the value, which seems correct. If I use ISXML(value) on the value in a CFdump, it returns true! Which seems to be a problem. If I use the variable in a query, the query fails and there is XML in the query statement that I didn't put there. Here is the SQL revealed in the error: Select full_name from qryClients where client_number="<?xml version="1.0" encoding="UTF-8"?><ClientSourceRecordIdentifier>9302045948</ClientSourceRecordIdentifier>" Is there a way to clean this XML cruft out of the variable? The variable by itself is supposed to be 9302045948.
d
https://cfdocs.org/deserializexml I would deserializeXML(your_variable) and cfdump that to see the object.
n
Thank you! I will try.
deSerialize Not supported on Lucee
d
My bad nate. Then you would have XmlParse(your_var) and then XmlSearch(parsed_xml, XPATH).
I tried to refresh my memory on XPATH, but I'm not quite getting the value in a variable. still trying...
n
This is how I am trying to assign the variable: <cfset clientTarget= "#toString(XMLDoc.TreatmentEpisodeDataSet.ProviderTreatmentEpisodes.ProviderTreatmentEpisode[MainIndex].ClientSourceRecordIdentifier)#">
d
I think you just needed
Copy code
.XmlText
at the end of your path:
Copy code
<cfset clientTarget= "#toString(XMLDoc.TreatmentEpisodeDataSet.ProviderTreatmentEpisodes.ProviderTreatmentEpisode[MainIndex].ClientSourceRecordIdentifier.XmlText)#">
or
Copy code
<cfset clientTargetNode= XmlSearch(XMLDoc, "/TreatmentEpisodeDataSet/ProviderTreatmentEpisodes/ProviderTreatmentEpisode[MainIndex]/ClientSourceRecordIdentifier)">
<cfset clientID = clientTargetNode[1].XmlText>
n
Interesting! Thanks for taking this on. I will give it a try tomorrow morning. I will do some reading on xmlsearch too.
Right now, orking with Xml feels like typing with oven mits on. Very awkward.
😂 1
@Daniel Mejia It is working! Thanks for pointing out my issue and correcting my course.
d
Nice. Your welcome