Solved

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

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to insert an Iframe into 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 : Open Page or Post…
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…

695 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