Solved

FIlter a SPRY XML file with Querystring from Parent Page

Posted on 2007-12-06
3
314 Views
Last Modified: 2013-11-12
Hello All,

I'm trying to do something simple, but for the life of me I can't get it to work out for me.  I'm new to SPRY for AJAX and my javascript is next to non-existant.

I have a normal ASP page passing a URLparam to another ASP page using an externally generated XML file.  I want this external XML to use the URL param to filter its recordset.

The external XML has a normal recordset behavior and the XML is generated in a Repeat Region.

I tried to include the URL param in the XML file recordset, but I don't think this XML can see the URL param.

Looking forward to hear from some Experts!!

0
Comment
Question by:jkdunbar
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 50 total points
ID: 20421017
It would help if you provided the XML structure and the filter parameter. But to give you an idea, lets your xml looks similar to this:
<states>
 <state abbr="CA" name="California">Hi</state>
 <state abbr="OR" name="Oregon">Bye</state>
</states>
and you want to get only California's data, then you would do it as follows:
var dsStates1 = new Spry.Data.XMLDataSet("states.xml", "/states/state[@abbr='CA']");
0
 
LVL 1

Author Comment

by:jkdunbar
ID: 20426579
This is the URL param I'm trying to pass to this page:
/image_gallery/images.asp?image_function=Retirement

The following is a snippet of my XML:

- <pictures>
- <image>
  <ID1>108</ID1>
  <image_category>Events</image_category>
  <image_function>Retirement</image_function>
  <image_path>/CFPU/Upload/../images/uploaded/27.jpg</image_path>
  <image_desc>Enter a description for this image</image_desc>
  <photo_year>2003</photo_year>
  <image_unit>CFPU HQ</image_unit>
  <approved>True</approved>
  <submitted>Dunbar</submitted>
  </image>
</pictures>

Thanks for pointing me in the right direction... maybe I can read up on this too.
0
 
LVL 1

Author Comment

by:jkdunbar
ID: 20426684
Got it!!!  I used this code as an example and modified it for my site:

 var params = Spry.Utils.getLocationParamsAsObject();

 var xpath = "/employees/employee";

   if ((params.lastname) && (params.firstname))
   xpath = "/employees/employee[lastname = '"+params.lastname+"' and firstname= '"+params.firstname+"']";
   
   var ds1 = new Spry.Data.XMLDataSet("../../data/employees-01.xml", xpath);


Works like a charm!!

I will still give you the 50 points for helping me to go in the right direction!!

Cheers!

Kev.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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 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 set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

803 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