Solved

Coldfusion escape a hyphen in coldfusion xml node

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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