ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 26th, 2011, 07:28 AM
absumter12 absumter12 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 31 absumter12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
XML page cannot be displayed

Well let me start of by saying im at the beginners level as a devleoper. My 1st task was to create an XML using coldfusion.

I started by writing it in notepad using the here is code below.


<?xml version="1.0" encoding="UTF-8"?>




<cfset xmlAmp = XmlNew() />



<cfset xmlRoot = XmlElemNew( xmlAmp, "", "man" ) />

<cfset xmlAmp.xmlRoot = xmlRoot />

<cfset xmlPersonality = XmlElemNew( xmlAmp, "", "Personality" ) />

<cfset ArrayAppend( xmlRoot.XmlChildren, xmlPersonality ) />

<cfset xmlspiritenergy = xmlElemNew( xmlAmp, "", "spiritenergy" ) />

<cfset ArrayAppend( xmlRoot.XmlChildren, Xmlspiritenergy ) />







<cfset xmlRoot.Personality.xmlAttributes.Fun = true />
<cfset xmlRoot.Personality.xmlAttributes.Happy = true />
<cfset xmlRoot.Personality.xmlAttributes.Nice = true />
<cfset xmlRoot.Personality.XmlAttributes.Generous = false />
<cfset xmlRoot.Personality.XmlAttributes.Evil = false />

<cfset xmlRoot.spiritenergy.xmlAttributes.Range = "3000km" />
<cfset xmlRoot.spiritenergy.xmlAttributes.Color = "Blue" />
<cfset xmlRoot.spiritenergy.xmlAttributes.Definition = "Good" />
<cfset xmlRoot.spiritenergy.xmlAttributes.Age = "30" />
<cfset xmlRoot.spiritenergy.xmlAttributes.Status = "Working" />

<cfdump
var="#xmlAmp#"
label="xmlAmp XML DOM" />



When i goto to display it under localhost:8500/"".xml I get an error message "A string literal was expected, but no opening quote character was found. Error processing resource 'http://localhost:8500/a...

<cfset xmlAmp = XmlNew() />

Was I suppose to include xmlAmp in the brackets?

Reply With Quote
  #2  
Old August 26th, 2011, 08:47 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
No, it is probably the XML tag you have at the top of your page. You don't need that.

Also, you may be doing this the hard way, because you could just create the string and then parse it into XML, something like this: http://tutorial18.learncf.com/

Reply With Quote
  #3  
Old August 29th, 2011, 07:30 AM
absumter12 absumter12 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 31 absumter12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
Hey thanks, now that I have this part done. Do I have to create a .cfm file to refer to this xml?

Im going to refer to the example you led me to above. I want to create a page that would allow me to search an artist or a title from a webpage.

Reply With Quote
  #4  
Old August 29th, 2011, 09:21 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
I'm not sure what you mean. At this point there is no XML file...you're creating it within the CF request. If you want to save it to disk, you'd need to use CFFILE to write it to the drive.

Reply With Quote
  #5  
Old August 29th, 2011, 09:39 AM
absumter12 absumter12 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 31 absumter12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
Well its like this, by the example given. I created the xml it contains my information title, aurthor, and isbn#.

To view the xml in a webpage do i just goto my browser and type http://localhost:8500/"".xml?

Reply With Quote
  #6  
Old August 29th, 2011, 12:33 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
If you're building up the XML using cfsavecontent, no. The XML is only in-memory and only exists for the duration of that request. If you want to write the XML to a file on disk, you must use cffile after you create the XML object.

Reply With Quote
  #7  
Old August 30th, 2011, 10:34 AM
absumter12 absumter12 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 31 absumter12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
Ok i was able to see what you were talking about. But I do have one question what could possibly be wrong with this line.

I keep returning the message of no variable set for producer


<cfsavecontent variable="amp2.xml"><?xml version="1.0"?>

<cfset Producers = xmlSearch(amp2.xml, 'Movies/Anime/title/producer')>
<cfoutput>

<h2>Producer Nodes</h2>
<cfloop from="1" to="#arraylen(producer)#" index="i">

<cfset producerXML = xmlparse(producer[i]) />
<b>Producer:</b> #ProducerXML.producer.xmlText#<br><br>
</cfloop>
</cfoutput>

Reply With Quote
  #8  
Old August 30th, 2011, 03:05 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
You're setting this to "producers" but you're referencing it later as "producer".

Reply With Quote
  #9  
Old August 30th, 2011, 03:53 PM
absumter12 absumter12 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 31 absumter12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
Thanks for pointing that out. I went to create a search button and i was successful with doing that.


But I want it return with a title from that xml. Would I be using a cfquery against the xml?

<cfset Animenodes = xmlSearch(amp2.xml, '/Movies/Anime')>
<cfoutput>
<h2>Anime Nodes</h2>
<cfform>
<div>
<b>title</b>
Title
<cfinput type="text" name="title">
<cfinput type="submit" name="submitButton" value="Search">
</div>
</cfform>
</cfoutput>

Reply With Quote
  #10  
Old August 30th, 2011, 07:54 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
cfquery has nothing to do with XML. You can just dump the data to see what its structure is by doing:

<cfset Animenodes = xmlSearch(amp2.xml, '/Movies/Anime') />
<cfdump var="#Animenodes#" />

Also, have you looked at the documentation on using XML with CF? It has full sections on creating XML and using XPath.

Reply With Quote
  #11  
Old August 31st, 2011, 04:33 AM
absumter12 absumter12 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 31 absumter12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
Ok i was able to dump the context of the XML out into a grid and I was able to do the different displaying of informatio using the tutorial.

But instead of dumping the information from the xml I wanted to make a search button for an end user to search the title or producer.

So far I got stuck here and I can get the searh button to display but I'm not sure how to get it to return with a title.


cfsavecontent variable="amp2.xml"><?xml version="1.0"?>

<Movies>

<Anime>
<title>Ties To Darkness</title>
<producer>Nicole Long</producer>
</Anime>
<Anime>
<title>Misty Fog</title>
<producer>Chris West</producer>
</Anime>

<Anime>
<title>Spirit of Echos</title>
<producer>Amp</producer>
</Anime>
</Movies>
</cfsavecontent>


<cfset amp2.xml = xmlParse (amp2.xml) />




<cfset Animenodes = xmlSearch(amp2.xml, '/Movies/Anime')>
<cfoutput>
<h2>Anime Nodes</h2>
<cfform>
<div>
<b>title</b>
Title
<cfinput type="text" name="title">
<cfinput type="submit" name="submitButton" value="Search">
</div>
</cfform>
<cfset amp2.xml = XMLParse(amp2.xml)>

<cfloop index="i" from="1" to ="#Arraylen(Anime)#">
<cfset AnimeXML = xmlparse(Anime[i])/>

<cfset Title = XMLSearch (amp2.xml,"/Movies/Anime/Title*[amp2.xml(title)='item'][#i#]/*[amp2.xml(title)='title']")>
<cfset title = title[1].xmltext>
</cfloop>
</cfoutput>

Reply With Quote
  #12  
Old August 31st, 2011, 09:56 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
XML isn't really a very robust mechanism for searching data, it is a storage and transport format. So you can use XPath to perform your searches against the XML if you want to, but it will get increasingly complex as the number of things you want to search for increases.

If the actual XML is going to contain more than a few sample nodes, you probably want to parse the XML and insert it into a database as actual relational data, and then search the database.

Reply With Quote
  #13  
Old August 31st, 2011, 11:34 AM
absumter12 absumter12 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 31 absumter12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
I didn't plan making it more bigger then just these few sample nodes.


But just for testing purposes where would I plug in my Xpath code to allow an end user inputdata to get Movies?

Reply With Quote
  #14  
Old August 31st, 2011, 01:21 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
On whatever page the form submits to. Right now you don't have a form action attribute defined, so by default it submits back to the same page.

You should also be able to do something like:

Code:
<cfsavecontent variable="amp2.xml"><?xml version="1.0"?>
<Movies>
<Anime>
<title>Ties To Darkness</title>
<producer>Nicole Long</producer>
</Anime>
<Anime>
<title>Misty Fog</title>
<producer>Chris West</producer>
</Anime>
<Anime>
<title>Spirit of Echos</title>
<producer>Amp</producer>
</Anime>
</Movies>
</cfsavecontent>

<cfset amp2.xml = xmlParse( amp2.xml ) />

<cfoutput>
	
<cfif StructKeyExists( form, 'title' )>

	<!--- Do XPath search based on form.title --->

<cfelse>	

	<h2>Anime Nodes</h2>
	<cfform>
	<div>
	<b>title</b>
	Title
	<cfinput type="text" name="title">
	<cfinput type="submit" name="submitButton" value="Search">
	</div>
	</cfform>

</cfif>

Last edited by kiteless : August 31st, 2011 at 01:25 PM.

Reply With Quote
  #15  
Old September 3rd, 2011, 07:12 PM
absumter12 absumter12 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 31 absumter12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
Ok you kind of lost me there.

I need plug in an Xpath search feature outside of the cfform?

Also how is the variable defined for <cfif StructKeyExists?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > XML page cannot be displayed

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap