Tuesday, 7 October 2014

posting php inside of xml



I'm trying to get php inside xml but I can't get it to run right. I can get the xml to run by it's self and the php to run by it's self, just can't get them to run together.



<?xml version="1.0"?>
<!DOCTYPE squad SYSTEM "squad.dtd">
<?xml-stylesheet href="squad.xsl?" type="text/xsl"?>

<squad nick="MyTAG">
<name>GROUP NAME</name>
<email>admin@website.com</email>
<web>http://ift.tt/1uYizGg;
<picture>Logo.png</picture>
<title>Multi-gaming Team</title>


<?php
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());




$sql = "SELECT fid37, fid38, fid39 FROM mytable WHERE fid37 IS NOT NULL";
$res = mysql_query($sql);

$xml = new XMLWriter();

$xml->openURI("php://output");
$xml->startDocument();
$xml->setIndent(true);

while ($row = mysql_fetch_assoc($res)) {
$xml->startElement('member');
$xml->writeAttribute('id', $row['fid38']);
$xml->writeAttribute('nick', $row['fid37']);

$xml->writeElement('name', $row['fid37']);
$xml->writeElement('email', 'N/A');
$xml->writeElement('icq', 'N/A');
$xml->writeElement('remark', $row['fid39']);

$xml->endElement('member');
}





//header('Content-type: text/xml');
$xml->flush();

?>

</squad>


where the output would be



<squad nick="MyTAG">
<name>GROUP NAME</name>
<email>admin@website.com</email>
<web>http://ift.tt/1uYizGg;
<picture>Logo.png</picture>
<title>Multi-gaming Team</title>

<member id="NUMBER" nick="NAME">
<name>NAME</name>
<email>N/A</email>
<icq>N/A</icq>
<remark>My REMARK</remark>
</member>

<member id="NUMBER" nick="NAME">
<name>NAME</name>
<email>N/A</email>
<icq>N/A</icq>
<remark>My REMARK</remark>
</member>
</squad>


anyone able to help me correct this?


No comments:

Post a Comment