Solved

Parsing xml data into coldfusion forms value field gives strange result.

Posted on 2006-11-24
2
160 Views
Last Modified: 2013-12-24
ok I have a generated xml file :
 <?xml version="1.0" encoding="UTF-8" ?>
- <mydoc>
  <firstname>john</firstname>
  <secondname>johnson</secondname>
  </mydoc>

____________________________________

I am trying to read into a  flash form form to pre populate it.
when I have value field with the variable the code :

<cfformgroup type="accordion">            
             <Cfformgroup type="page" label="Stage 1 - Personal details">
          <cfinput name="fname" type="text" id="fname" size="12" maxlength="15"  label="first name" value="#mydoc1.MyDoc.firstname#">
              <cfinput name="sname" type="text" id="sname" size="12" maxlength="15"  label="surname" value="#mydoc1.mydoc.secondname#">  

I get the following result showing in the form box:
_________________________________________
<?xml version="1.0" encoding="UTF-8"?>

<firstname>

                        john

                  </firstname>
 ________________________________________


If i simply create a page with the variables output on it i get the right result i.e

<cfset
mydoc1=XMLParse("c:\domains\anyname.co.uk\db\myxmldoc.xml")>

<cfoutput>

#mydoc1.mydoc.firstname# is the first name <br>
#mydoc1.mydoc.secondname# is the second name

gives the output

 john is the first name
johnson is the second name

__________________________________________

Well I hope it makes sense to you because It is driving me mad!

regards
John

0
Comment
Question by:finchdata
[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
2 Comments
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 18021004
in your bit of code, you were just referencing the node in the xml document, you have to specify what in that node you want to display...

give this a try...

<cfformgroup type="accordion">            
           <Cfformgroup type="page" label="Stage 1 - Personal details">
          <cfinput name="fname" type="text" id="fname" size="12" maxlength="15"  label="first name" value="#mydoc1.MyDoc.firstname.xmlText#">
            <cfinput name="sname" type="text" id="sname" size="12" maxlength="15"  label="surname" value="#mydoc1.mydoc.secondname.xmlText#">
0
 
LVL 20

Accepted Solution

by:
trailblazzyr55 earned 500 total points
ID: 18021058
this...

<cfset mydoc1=XMLParse("c:\domains\anyname.co.uk\db\myxmldoc.xml")>

<cfoutput>
#mydoc1.mydoc.firstname# is the first name <br>
#mydoc1.mydoc.secondname# is the second name
</cfoutput>

should have produced something similar to this...

coldfusion.xml.XmlNodeList@10068d8 is the first name
coldfusion.xml.XmlNodeList@1e36faf is the second name

and that's because it's referencing the node itself...

with your XML

  <mydoc>
  <firstname>john</firstname>
  <secondname>johnson</secondname>
  </mydoc>

the values between <firstname>john</firstname>, in this case "john" is known as the "xmlText"
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

726 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