Solved

FIlter a SPRY XML file with Querystring from Parent Page

Posted on 2007-12-06
3
315 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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

821 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