Solved

Cookies in XML

Posted on 2001-06-18
4
1,778 Views
Last Modified: 2012-08-13
How do I get data from cookies in XML ?
I have a code in java script and I want to write the same in xml. Can I use the same code ?

<script>

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

var name=GetCookie("product")
</script>

thanks.
0
Comment
Question by:yonit
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
sachiek earned 100 total points
ID: 6205122


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:user="http://www.w3.org/TR/WD-xsl" xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0">
<xsl:template match="/">

<SCRIPT LANGUAGE="Javascript">
<xsl:comment><![CDATA[

function getCookieVal (offset) {
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1)
   endstr = document.cookie.length;
 return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
 var arg = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i < clen) {
   var j = i + alen;
   if (document.cookie.substring(i, j) == arg)
     return getCookieVal (j);
   i = document.cookie.indexOf(" ", i) + 1;
   if (i == 0) break;
 }
 return null;
}

var name=GetCookie("product")


]]></xsl:comment>

</HEAD>
<BODY onLoad="getCookieVal(parametername)">


--------------------

Hi there
  Hope u understand how u should call that function now with XSL and invoke it will xml stuffs.
 

Let me know how about u got doubts next..

Sachi
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6790122
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.
____________________________________________
---------->  Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

------------->  The ALL TOPICS link has been updated today to reflect all the new TAs.

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6941244
<review>

<recommendation>
points to sachiek and grade A. syntactical error minor.
</recommendation>

<objection>
any objection should be raised within 7 days
</objection>

<reviewer>
b1xml2
</reviewer>

</review>
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6942983
Thank you very much b1xml2 for your help here.  That is very much appreciated.  I have finalized this question and will forego an additional 7 day waiting period, inasmuch as I posted a request in February which did not get a response of any kind.

Moondancer - EE Moderator
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Image decoding from Camera 3 96
Formatting issues in XSL FO 3 44
XSLT 1.0 - Finding Substrings from the End of a String 3 32
Need a modeling tool 2 19
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…

820 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