Solved

Coldfusion escape a hyphen in coldfusion xml node

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now