<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Having trouble reading XML from an external script</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1597" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007>Julian, thanks so much for the quick response!
Adding a new feature overnight is unprecedented in my
experience!</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007>Yes, it is working great! It took me a little time to
figure out how to create the object holding the variables I sent from Xerte to
PHP, but once I got that going it was very easy to work
with.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007>For the interest of anyone else, here is how I set up
my test:</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007>In Xerte, I added a page and set an id of 'varPage' for
it. I then added a script icon, with the following code to set up and send my
variables to a PHP page:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007></SPAN></FONT> </DIV>
<DIV><FONT face="Courier New" size=2><SPAN class=796065515-30082007>vars = new
LoadVars ();<BR>vars.type = 'SELECT';<BR>vars.table = 'tableName';<BR>vars.id =
myId;<BR>vars.sort = 'fname';</SPAN></FONT></DIV>
<DIV><FONT face="Courier New" size=2><SPAN
class=796065515-30082007></SPAN></FONT> </DIV>
<DIV><FONT face="Courier New" size=2><SPAN
class=796065515-30082007>varPage.sendAndLoadVars('http://localhost/test/test_xerte2.php',
vars);</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=796065515-30082007>My
test_xerte2.php page just receives and regurgitates the variables in a
name/value pair, but I added a name/value pair that did not come from
Xerte:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007></SPAN></FONT> </DIV>
<DIV><FONT face="Courier New" size=2><SPAN
class=796065515-30082007><?php # test_xerte2.php</SPAN></FONT></DIV>
<DIV><FONT><SPAN class=796065515-30082007><FONT face="Courier New"
size=2>foreach ($_POST as $varname => $varvalue) {<BR> if
(empty($varvalue)) {<BR> $empty[$varname] =
$varvalue;<BR> } else {<BR> $post[$varname] =
$varvalue;<BR> echo "$varname=$varvalue&";<BR>
}<BR>}</FONT></SPAN></FONT></DIV>
<DIV><FONT><SPAN class=796065515-30082007><FONT face="Courier New" size=2>echo
"newField=newFieldValue"; // new var that didn't come from Xerte</FONT></DIV>
<DIV><FONT face="Courier New" size=2>?> </FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV></SPAN></FONT><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff
size=2>Back in Xerte, I have an interaction icon, with an event response hanging
off it. In the properties of the response I have eventName set to
'onSendAndLoadVars' and the icon property is set to 'varPage'. The script icon
added to the response had the following code:</FONT></SPAN></DIV>
<DIV><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=796065515-30082007><FONT face="Courier New" size=2>type =
varPage.loadVars.type;<BR>table = varPage.loadVars.table;<BR>eid =
varPage.loadVars.id;<BR>order = varPage.loadVars.sort;</FONT></SPAN></DIV>
<DIV><SPAN class=796065515-30082007><FONT face="Courier New" size=2>newField =
varPage.loadVars.newField;</FONT></SPAN></DIV>
<DIV><SPAN class=796065515-30082007><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=796065515-30082007><FONT face="Courier New"
size=2>replyPage.myText = '<p><b>Response from script:
</b></p><br />';</FONT></SPAN></DIV>
<DIV><SPAN class=796065515-30082007><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=796065515-30082007><FONT face="Courier New"
size=2>replyPage.myText += '<br />Query Type: <i>' + type +
'</i>';<BR>replyPage.myText += '<br />Table Name: <i>' + table
+ '</i>';<BR>replyPage.myText += '<br />ID: <i>' + eid +
'</i>';<BR>replyPage.myText += '<br />Order By: <i>' + order +
'</i>';</FONT></SPAN></DIV>
<DIV><SPAN class=796065515-30082007><FONT face="Courier New"
size=2>replyPage.myText += '<br />New Field: <i>' + newField +
'</i>';</FONT></SPAN></DIV>
<DIV><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff size=2>Notice
that all you have to do to reference a variable returned by PHP is refer to its
property in the loadVar object. Even variables created in the PHP script can be
accessed this way, but you have to know the name of the variable created in PHP
in order to get its value from the object in Xerte. </FONT></SPAN></DIV>
<DIV><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff size=2>There
must be a way to get a list of all properties of an object, but I haven't found
the function that does this. Is there such a function, or snippet of code, that
will return a list of all the property names? How about a count of the number of
properties, is there a function for that?</FONT></SPAN></DIV>
<DIV><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff size=2>Thanks
again, Julian!</FONT></SPAN></DIV>
<DIV><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=796065515-30082007><FONT face=Arial color=#0000ff size=2>-
Paul</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=796065515-30082007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><BR></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> xerte-bounces@lists.nottingham.ac.uk
[mailto:xerte-bounces@lists.nottingham.ac.uk] <B>On Behalf Of </B>Tenney
Julian<BR><B>Sent:</B> Thursday, August 30, 2007 1:21 AM<BR><B>To:</B> Xerte
discussion list<BR><B>Subject:</B> [Xerte] LoadVars<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007>Paul,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007>If you download Xerte form the website now, I have
aded IconID.loadVars(url) and IconID.sendAndLoadVars(url,
loadVarsObjToSend);</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007>The events to listen for are onLoadVars and
onSendAndLoadVars. In both cases the resulting loadVars object is
IconID.loadVars.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007>Can you test it and let me know it works to your
satisfaction?</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007>thanks,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Verdana color=#0000ff size=2><SPAN
class=067341708-30082007>Julian</SPAN></FONT></DIV><BR>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><FONT face=Arial color=#0000ff
size=2></FONT> </BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>