Having a hard time parsing XML created from a web-form using POST.
Here's the scenario:
1) User comes to a web-page, enters their name into a text-field, and clicks SUBMIT
2) This calls a PHP file (called "makeXML.php") which generates an XML file containing that user's name in a tag called "currentUserName"
3) an iPhone App then loads this "makeXML.php" file (using 'loadXMLByURL') and parses it, looking specifically to output the contents of the "currentUserName" tag into a UILabel object.
Should be pretty simple - but for some reason, the contents of the "currentUserName" tag are coming up empty in the App - though they show up perfectly well in the generated XML code in the browser.
What's even stranger, is that if I instead hard-code a value to "uName" in the PHP file ("makeXML.php") - as opposed to getting that value from the FORM (using $_POST["userName"];) - it all works perfectly well. I'm able to grab the value from the "currentUserName" tag and output it to the UILabel object.
NSXMLParser seems to just not like POST'ed values for some reason.
Any ideas?
Here's the code:
portal.html:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Web-Form</title>
</head>
<body>
<form name="form1" method="post" action="makeXML.php">
<p>Enter your name:</p>
<p>
<input name="userName" type="text" />
</p>
<p>
<input type="submit" value="SUBMIT" />
</p>
</form>
</body>
</html>
Here is "makeXML.php":
<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
echo "<document>";
$uName = $_POST["userName"];
echo "Here is the name you typed:";
echo "<br/>";
echo "<theUsersName>$uName</theUsersName>";
echo "</document>";
?>
Here is the outputted code from makeXML.php: (Note that this code comes out all on one line - is that how its supposed to be? Shouldn't the "br" tag be working and forcing a line break there?)
<?xml version="1.0" encoding="UTF-8" ?><document>Here is the name you typed:<br/><theUsersName>johnson</theUsersName></document>
Again, note that if I replace:
$uName = $_POST["userName"];
with plain-old:
$uName = "John";
Everything works perfectly and the name "John" appears correctly in my UILabel...