Solved

Coldfusion escape a hyphen in coldfusion xml node

Posted on 2012-04-12
2
935 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is there any Artificial Intelligence (AI) Software I can use with my database search engines? 1 81
coldfusion, jQuery help 25 98
XML XSLT If loop 4 26
XML SQL 8 25
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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