Solved

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

Posted on 2006-11-24
2
153 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

744 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

12 Experts available now in Live!

Get 1:1 Help Now