Copy link to clipboard
Copied
I have XML string like this
<Request><Header><UserId>pgh</UserId><Token>05032015T1105144</Token></Header></Request>
How can I extract the <UserId> and <Token> values only?
So for the above string --I want the values
pgh
05032015T1105144
I want to set these 2 values to variables like this...everything else in the string goes away
<CFSET userid =pgh>
<CFSET token = 05032015T1105144>
So you START with this
<Request><Header><UserId>pgh</UserId><Token>05032015T1105144</Token></Header></Request>
And END with this
<CFSET userid =pgh>
<CFSET token = 05032015T1105144>
Copy link to clipboard
Copied
Looks like this is related to your other thread. How far did you get with things, were you able to parse the XML?
Copy link to clipboard
Copied
Yes it is related to the post you mention.
I was able to extract the info....
now the partner firm is requesting that I send back this xml (see below) to them...any idea on how I would do that?
</Response
Copy link to clipboard
Copied
The forum must have eaten your code. Try using the insert code button ie ">>".
now the partner firm is requesting that I send back this xml (see below) to them...any idea on how I would do that?
But we seem to have switched gears. Are you saying you have figured out how to extract values from your XML and now need to generate XML instead?
Copy link to clipboard
Copied
Yes I HAVE figured out how to extract the needed values from the xml..
NOW I need to send back this xml (see below) to them...any idea on how I would do that?
Patrick Hutchinson
Copy link to clipboard
Copied
Well FIRST you need to figure out how to post your code/xml so we can actually see it ...
Copy link to clipboard
Copied
Well actually...a new problem keeps arising as I move forward.
I finally have been able to extract the xml and send a request back to the partners server...
So all of that has been resolved.
Now the partner tells me that my <cfhttp request is A NEW SESSION and that I needed to keep the same session that
Patrick Hutchinson
www.1design.com
Office: 804-360-0695
Cell: 804-370-6873
Email: pat@1design.com
Copy link to clipboard
Copied
There are a few ways you could do this, but the easiest is probably to use the XmlParse function, eg:
<cfset xmlObj = XmlParse(xml)>
You should then be able to do something like this:
<cfoutput>
#xmlObj.XmlRoot.Header.UserId#
#xmlObj.XmlRoot.Header.Token#
</cfoutput>
You can do a cfdump on the xmlObj to see all the variables at your disposal. You might need to append an XML declaration to the beginning of your XML, eg:
<?xml version="1.0" encoding="UTF-8"?>