Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Coldfusion escape a hyphen in coldfusion xml node

Posted on 2012-04-12
2
Medium Priority
?
980 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
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 …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

722 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