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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.