Jump to content

Graceful degradation and mixing the task/s between php5 & Javascript


GURAQTINVU

Recommended Posts

I have been here before but at a lower level and am know paying for my workaround.

 

I have a single xml file that supplies all the necessary page specifics for the site, including image details and text:

 

<?xml version="1.0" encoding="utf-8"?>
<thepages>
<pageindex>
<headdiv>WELCOME</headdiv>
<bodydiv>
<p>First paragraph.</p><p>Second<b><em>small</em></b>paragraph.</p>
</bodydiv>
<images>
<image1>
<title>Image One</title>
<img id="Placeholder" src="images/picone.png" alt="Do not point!" width="170" height="235" />
</image1>
</images>
</pageindex>
<pagetwo>
<headdiv>Another Page</headdiv>
.
.
</thepages>

 

To populate the required page, I have written a function that detects the existence of and subsequently the value of a Query String.  If tJavascript is off, the php returns JUST the relevant page details as an array of SimpleXML objects and the various '<divs>' in the recipient page are 'echoed' with the necessary (all coded and working fine).  If Javascript is on, I want the same to happen, but I haven't managed to return JUST the relevant page details as xml that Javascript can then parse having assigned the data from the responseXML property - the only time that javascript returns data in the responseXML is when php uses this code:

 

ob_clean(); header('Content-type: text/xml'); flush(); readfile($filePathName);

 

The route I thought should work, extracted the string and tags (which together represented he desired page) from the xml file using:

 

$simpleXMLArray  = $xml->xpath($entireXMLPathRequired);
while(list( , $node) = each($simpleXMLArray)) {
		$mySimpleXMLString .= trim($node->asXML());
	}
	echo '<?xml version="1.0" encoding="utf-8"?>'.<outer>$mySimpleXMLString.</outer>;

 

I have tried everything including saving a new file and then using 'readfile()', but but I just can't get it to play ball.

 

If anyone has an insight into the problem I would be grateful - many thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.