Solved

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

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Recipient address rejected: User unknown in virtual alias table 1 294
Internal DNS Zone Issue 13 74
Blue Coat API portal URL 2 164
New OSQA server has a ton of fake users 4 64
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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 add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

810 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