Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
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…

895 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

16 Experts available now in Live!

Get 1:1 Help Now