0

I am trying to get this to work but I've been having a difficult time pulling it together. After implementing the code and making small changes where I've seen suggested doesn't help. This isn't a work or school related project. Just something to make my hobbies easier. So I have a form on a web page that I can submit data to. The API that I submit data to replies back in XML. This is working. I can pass data from a form to the API and get the raw XML. But It's not easy to read. So I've created a php file to hopefully pull the XML and arrange it in a way that is easier to read.

The systen in place works like the following:

HTML File

<form method="post" action="search.php">
value0:<input type="text" size="12" maxlength="12" name="0"><br />
value1:<input type="text" size="12" maxlength="36" name="1"><br />
value2:<input type="checkbox" value="2" name="2"><br />
<input type="submit" value="submit" name="submit">
</form>

PHP File

<?php
$zero = $_POST['0'];
$one = $_POST['1'];
$two = $_POST['2'];
$url = "http://www.website.com/file.asmx/p?apikey=XXXXXX&two='. $two .'&zero='. $zero .'"
$xml = json_decode($url);
$three = $xml->attribute1;
$four = $xml->attribute2;
$five = $xml->attribute3;
/*Form Debug*/
echo "<br>"
echo $_POST['0'];
echo "<br>"
echo $_POST['1'];
echo "<br>"
echo $_POST['2'];
echo "<br>"
/*/Form Debug*/

echo "V1: " . $three . "<br>";
echo "V2: " . $four . "<br>";
echo "V3: " . $five . "<br>";

?>

Results back from API in UTF-8 XML V1

<products>
<item>
<attribute0>11407</attribute0>
<attribute1>12345</attribute1>
<attribute2>abcde</attribute2>
<attribute3>!@#$%</attribute3>
<link>http://www.website.com</link>
</item>
</products>

1 Answers1

0

There is another SO question that has a very similar answer about how to create a desirable XML format using SimpleXML (PHP).

Take a look here:

PHP XML how to output nice format

Community
  • 1
  • 1
Graham S.
  • 1,480
  • 1
  • 20
  • 28
  • I'm not trying to get an XML result. I am actually getting that already. I just need to parse the results into an HTML formatted page. So I can have a picture with item descriptions underneath. The first page (Forms) takes input and appends it to a URL which gives me back an XML UTF-8 result that I want to parse into a php document and display as HTML. If that makes sense. – Russell Gradert Feb 06 '15 at 19:54
  • I almost understand what you're saying but can you clarify on *I want to parse into a php document and display as HTML.*? Because if I understand you correctly I would consider creating a php script at the top of the page you want to display and parse through the XML there, and then echo it out accoringly to your page. – Graham S. Feb 06 '15 at 21:17