The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> ColdFusion Development
|
Page 2 -
XML page cannot be displayed
Page 2 - Discuss XML page cannot be displayed in the ColdFusion Development forum on Dev Shed. XML page cannot be displayed ColdFusion Development forum discussing CFML coding practices, tips on CFML, and other CFML related topics. Find out why ColdFusion is the tool of choice for many e-commerce developers.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 3rd, 2011, 07:21 PM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 31
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
|
|
|
Well l've been kinda chasing an alt. route with this xml task.
I got all they way to the portion of page where I was defining
my search option and it blows up right in my face. Could you
let me know if I'm tackling it the right way?
xml file:
<album>
<title>Questions, unanswered</title>
<artist>Steve and the flubberblubs</artist>
<year>1989</year>
<tracks>
<song tracknumber="1" length="4:05">
<title>What do you know?</title>
<artist>Steve and the flubberblubs</artist>
<lastplayed>2006-10-17-08:31</lastplayed>
</song>
<song tracknumber="2" length="3:45">
<title>Who do you know?</title>
<artist>Steve and the flubberblubs</artist>
<lastplayed>2006-10-17-08:35</lastplayed>
</song>
<song tracknumber="3" length="5:14">
<title>When do you know?</title>
<artist>Steve and the flubberblubs</artist>
<lastplayed>2006-10-17-08:39</lastplayed>
</song>
<song tracknumber="4" length="4:19">
<title>Do you know?</title>
<artist>Steve and the flubberblubs</artist>
<lastplayed>2006-10-17-08:44</lastplayed>
</song>
</tracks>
</album>
mycfm:
<cfhttp url="http://localhost:8500/interviewtest/music.xml">
<!---<cfdump var="#cfhttp.FileContent#">--->
<cfset music = xmlparse("#cfhttp.FileContent#")>
<!---<cfdump var="#music#" label= "xml document object">--->
<cfset armusic=music.album.tracks.song>
<!---<cfdump var="#armusic[1].artist.xmltext#" label="armusic">--->
<cfscript>
if (isDefined("form.submitbutton"))
{
hql = "FROM armusic WHERE 0=0";
}
</cfscript>
<Title>Artist Search</Title>
<body>
<cfform>
<table border ="0">
<tr>
<td>Artist Search:
</td>
<td><input type="text" name="artist" size="30" </td>
</tr>
<tr>
<td><input type="submit" value="search" name="submitbutton"
</td>
</tr>
</table>
</cfform>
<cfif isDefined(armusic)>
</cfif>
/body>
|

September 4th, 2011, 01:15 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
"Blows up in your face" doesn't provide any information I can use. Do you get an error? You've got to explain what happens, I can't read your mind.
Beyond that, I have no idea what this is:
Code:
if (isDefined("form.submitbutton"))
{
hql = "FROM armusic WHERE 0=0";
}
I also don't see any XPath in this code. I asked earlier but you didn't answer so I'll try again: have you actually read the CF documentation that covers XML and XPath?
|

September 5th, 2011, 03:32 AM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 31
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
|
|
|
Ok sorry the message that I was getting with the code earlier had a problem with the script that i wanted to get working.
So I ended up going back to using the Xpath function. I was able to create a cfscript using an array that retrieves the title of the songs from the xml. I tested by using a writoutput tag in the script.
Now my only problem is that I can't seem to get this Search button to return the title. Please see below.
<cfhttp url="http://localhost:8500/interviewtest/music.xml">
<cfset music = xmlparse("#cfhttp.FileContent#")>
<!---<cfdump var="#cfhttp.FileContent#">--->
<!---<cfdump var="#music#" label= "xml document object">--->
<cfset armusic=music.album.tracks.song>
<cfscript>
if (isDefined("form.submitbutton"));
music = xmlparse("#cfhttp.FileContent#");
selectedElements = XmlSearch(music, "/album/tracks/song/title");
for (i = 1; i LTE Arraylen(selectedElements); i = i + 1)
writeoutput (selectedElements[i].xmltext & "<br>");
</cfscript>
<Title>Artist Search</Title>
<body>
<cfform>
<table border ="0">
<tr>
<td>Artist Search:
</td>
<td><input type="text" name="artist" size="30" </td>
</tr>
<tr>
<td><input type="submit" value="search" name="submitbutton"
</td>
</tr>
</table>
</cfform>
<cfif isDefined("selectedElements")>
</cfif>
|

September 5th, 2011, 08:55 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
Where are you matching the title?
|

September 6th, 2011, 07:46 AM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 31
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
|
|
|
How would i match the title?
|

September 6th, 2011, 07:48 AM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 31
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
|
|
|
I have created that script using the XMLSearch array. I though that was all that was needed to allow me to search.
The reason why is because when i use the writeoutput tag in my cfscript it gives me all the titles.
|

September 6th, 2011, 08:17 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
That's because you're not using the value they entered into the form, but are just pulling out ALL of the titles.
|

September 6th, 2011, 09:40 AM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 31
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
|
|
|
So should I be changing if (isDefined("form.submitbutton"));
to if(isDefined("form.search"))?
|

September 6th, 2011, 11:23 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
No, you're missing the point. If your XPath search doesn't limit what it looks for to the value passed by the user in form.artist, how can you expect it to do anything OTHER than returning all of the artists? You're not filtering anything.
|

September 6th, 2011, 12:19 PM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 31
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
|
|
|
ok now i see a little light..... about the filtering do I have to add a filter to my script? and if so what kind of tag would it be?
|

September 6th, 2011, 02:13 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|

September 7th, 2011, 06:06 PM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 31
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
|
|
|
ok thanks.......
Now I another question. I createded a .cfc file and a action cfm file to reference to it. I am plotting to create a grid in the cfm to display my xml files. Which were in previous post
I also want to be able to delete the data in this grid and add so that it writes back to the xml.
I think i got it pretty much covered but I get an error when loading my cfm The message states.
Error invoking CFC "path leading to my cfc file:"The row number 1 is out of bounds.
I assume that it may have something to do with one of my query's but im not to sure. Also thanks for all your help.
<cfcomponent name="ArtistDataManager">
<cffunction name="getArtist" access="remote" output="false" returnFormat="plain">
<cfhttp url="http://localhost:8500/interviewtest/music.xml">
<cfset biggie = xmlparse ("#cfhttp.FileContent#")>
<cfcontent type="text/xml" reset="yes">
<cfreturn biggie>
</cffunction>
<cffunction name="getData" access="remote" output="false">
<cfargument name="page" required="yes">
<cfargument name="pageSize" required="yes">
<cfargument name="sortCol" required="yes">
<cfargument name="sortDir" required="yes">
<cfargument name="filter" required="no">
<cfhttp url="http://localhost:8500/interviewtest/music.xml">
<cfset biggie = xmlparse ("#cfhttp.FileContent#")>
<cfset txe = biggie.album.tracks.song>
<cfset box = arraylen(txe)>
<cfset myquery = QueryNew("title, artist")>
<cfloop index="i" from = "1" to = #box#>
<cfset temp = QuerySetCell (myquery, "artist", #biggie.album.tracks.song[i].artist.xmltext#, #i#)>
<cfset temp = QuerySetCell (myquery, "title", #biggie.album.tracks.song[i].title.xmltext#, #i#)>
</cfloop>
<cfquery name="Search" datasource="myquery">
select TITLE, ARTIST from SONG
<cfif isDefined("arguments.filter") AND arguments.filter NEQ "">
where GENRE = '#arguments.filter#'
</cfif>
<cfif arguments.sortCol NEQ "" AND arguments.sortDir NEQ "">
order by #arguments.sortCol# #arguments.sortDir#
<cfelse>
order by TITLE ASC
</cfif>
</cfquery>
<cfreturn QueryConvertForGrid(Search, arguments.page,
arguments.pageSize)>
</cffunction>
<cffunction name="getArttitle" access="remote" output="false">
<cfargument name="prodname" default="The Song">
<cfquery name="SongDetails" datasource="myquery">
select TITLE, ARTIST from SONG
where TITLE = '#arguments.prodname#'
</cfquery>
<cfoutput>
<cfxml variable="MUSICXML" >
<album>
<title>Questions, unanswered</title>
<artist>Steve and the flubberblubs</artist>
<year>1989</year>
<tracks>
<song tracknumber="1" length="4:05">
<title>What do you know?</title>
<artist>Steve and the flubberblubs</artist>
<lastplayed>2006-10-17-08:31</lastplayed>
</song>
<song tracknumber="2" length="3:45">
<title>Who do you know?</title>
<artist>Steve and the flubberblubs</artist>
<lastplayed>2006-10-17-08:35</lastplayed>
</song>
<song tracknumber="3" length="5:14">
<title>When do you know?</title>
<artist>Steve and the flubberblubs</artist>
<lastplayed>2006-10-17-08:39</lastplayed>
</song>
<song tracknumber="4" length="4:19">
<title>Do you know?</title>
<artist>Steve and the flubberblubs</artist>
<lastplayed>2006-10-17-08:44</lastplayed>
</song>
</tracks>
</album>
</cfxml>
</cfoutput>
<!--- Convert the XML object to an XML string. --->
<cfset xmldata = xmlparse(musicxml)>
<cfcontent type="text/xml" reset="yes">
<cfreturn xmldata>
</cffunction>
</cfcomponent>
|

September 7th, 2011, 11:28 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
You're showing the CFC, not the code that is calling the CFC. The error should have a file and line number where the error is happening.
|

September 8th, 2011, 12:56 PM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 31
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
|
|
|
The error message state the following:
Error invoking CFC/ColdfusionProject/artistdatamanager.cfc: The row number 1 is out of bounds.[Enable debugging by addming'cfdebug to our URL parameters to see more information]
|

September 8th, 2011, 01:00 PM
|
|
Contributing User
|
|
Join Date: Aug 2011
Posts: 31
Time spent in forums: 3 h 50 m 17 sec
Reputation Power: 2
|
|
|
Getting this message when i try to put up my cfm code to the forum.
Could not find phrase 'akismetspam'.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|