Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7661319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:34:57+00:00 2026-05-31T13:34:57+00:00

I am using ColdFusion 8. I am parsing an XML document and need to

  • 0

I am using ColdFusion 8.

I am parsing an XML document and need to get at a single value that is buried deep in the document. I am successfully parsing the document and getting the values I need, but it seems that there has to be a more efficient means to get to the same data.

I have NOT parsed much XML. Is having to test for the existence of keys this deep very typical in parsing XML or am I doing something wrong? Is there a better way to code this?

// PARSE THE SOAP RESPONSE 
SoapResponse = xmlParse(httpResponse.fileContent);
// PUT THE RESPONSE NODES INTO AN ARRAY
ResponseNodes = xmlSearch(SoapResponse, "//*[ local-name() = 'OnlineBoothInformation' ]");

// LOOP THROUGH THE ARRAY AND GET EACH NODE
for (i = 1; i lte arrayLen(ResponseNodes); i++) {
  // CREATE NEW STRUCTURE TO HOLD BOOTH DATA
  BoothInfo  = structNew();

  // TEST FOR CUSTOM FIELDS TO FIND NEW EXHIBITOR
  BoothInfo.NewExhibitor = 0; // DEFAULT NEW EXHIBITOR
    if (structKeyExists(ResponseNodes[i], "CustomFields")) {
      CustomFields = xmlParse(ResponseNodes[i].CustomFields);
      for (j = 1; j lte arrayLen(CustomFields); j=j+1) {
        if (structKeyExists(ResponseNodes[i].CustomFields[j], "Field")) {
          Field = xmlParse(ResponseNodes[i].CustomFields[j].Field);
          for (k = 1; k lte arrayLen(Field); k=k+1) {
            if (ResponseNodes[i].CustomFields[j].Field[k].XmlAttributes.Name == "New Exhibitor") {
        BoothInfo.NewExhibitor = 1;
    }
          }
        }
      }
    }
  }

I am getting other values for the BoothInfo structure. They were MUCH easier to get at. I did not include them in this example.

UPDATE

I was able to rewrite the code and get at what I needed much more efficiently.

// NEW EXHIBITOR
BoothInfo.NewExhibitor = 0;
if (structKeyExists(ResponseNodes[i].CustomFields, "Field")) {
    Fields = ResponseNodes[i].CustomFields.Field;
    for (j = 1; j lte arrayLen(Fields); j++) {
        if (Fields[j].XmlAttributes.Name == "New Exhibitor") {
            BoothInfo.NewExhibitor = 1;
    break;
        }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:34:57+00:00Added an answer on May 31, 2026 at 1:34 pm

    Well, I don’t see why you’re calling xmlParse over and over. You use that to convert a string to an XML nodeset, but you already have an XML nodeset.

    You can use a more specific XPath specification for the nodes you want. Maybe something like, //*[ local-name() = 'OnlineBoothInformation' ]/CustomFields/Field[@Name="New Exhibitor"]. Then you can just check whether an empty array was returned. XPath is really expressive, but it takes some getting used to. Take care that while CF is generally not case-sensitive, XPath is. I copied the case from your CF, but that has to match the case in the XML in order to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ColdFusion to populate a template that includes HTML unordered lists ( <ul>
Using CFML (ColdFusion Markup Langauge, aka ColdFusion), how can you compare if two single
I am using ColdFusion 9.1.0. I am working on part of a site that
I am using ColdFusion (Railo 3.3), and I have several forms using jQuery that
I am using ColdFusion 9.0.1. I have a new web site that uses Bikes.cfm
I have a collection of strings that need to be parsed (using RegEx patterns)
I am using ColdFusion 9.0.1 I have a new site that is accessible through
I'm using ColdFusion with Microsoft SQL Server 2005 and on occasion I get this
I'm using coldfusion to insert the contents of a struct (key-value pairs) into a
I'm working on a Fusebox application using Coldfusion, and there is a fusebox.xml file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.