Solved

Coldfusion escape a hyphen in coldfusion xml node

Posted on 2012-04-12
2
946 Views
Last Modified: 2012-04-12
<cfsavecontent variable="objxml">
   <VehicleInfo Year="2010" Make="BMW" Model="328I SULEV">        
   <Sub-Model>CONVERTIBLE</Sub-Model> <Sub-Model>COUPE</Sub-Model>  
   <Sub-Model>SEDAN 4 DOOR</Sub-Model> </VehicleInfo>
</cfsavecontent>
     
         <cfset submodelNodes = xmlSearch( objxml, "/VehicleInfo/Sub-Model")>  
          <cfset submodelArray = []>
          <cfloop array="#submodelNodes#" index="Sub-Model">
             <cfset arrayAppend(submodelArray,"sub-model".xmlText)>
         </cfloop>

This is  causing an issue with the "-" in the coldfusion any ideas how to get around it?

The dash in the cfloop and in the cfset is being looked at as a range in coldfusion.

Any Ideas how to get around it?
0
Comment
Question by:LeadCo
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 37841079
<cfset submodelNodes = xmlSearch( objxml, "/VehicleInfo/Sub-Model")>  

That returns an array of "Sub-Model" nodes. So you don't even need to use "Sub-Model".  Just use:

        ...
       <cfset submodelNodes = xmlSearch( objxml, "/VehicleInfo/Sub-Model")>  
       <cfset submodelArray = []>
       <cfloop array="#submodelNodes#" index="currentNode">
             <cfset arrayAppend(submodelArray, currentNode.xmlText)>
         </cfloop>
0
 

Author Comment

by:LeadCo
ID: 37841089
Perfect!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Word files to Wordpress Posts 2 65
XML Data Missing in PHP SimpleXML 8 71
what are list of ebay api errors 1 28
Coldfusion cfc script file to cfc with cffunction help 5 29
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question