Jump to content

Getting xml using simplexml but how to style it?


cparekh

Recommended Posts

Hi all,

 

I'm using php/simplexml to pull some xml and I'm having trouble styling it - essentially I'm not sure what to do.

 

I've read up on xslt but it seems the call to a xsl document needs to be made from within the feed but what I have is just html from simplexml.

 

How would I apply styling?  :-[

 

This is really something I know very little about so any help or guidance is greatly appreciated.

 

Thanks,

C.

Link to comment
Share on other sites

As sloth has mentioned, if you can read and parse the XML file then you're almost there.

 

As you're probably aware XML is just plain text with labels saying what the file contains.

 

For example...

<car id="1">
  <color>Red</color>
  <make>Mazda</make>
</car>

 

Here we can see what the data contains but now it's up to you to format this data in your browser. For example:

Car #: 1
Make: Mazda
Color: Red

Link to comment
Share on other sites

Hi,

 

firstly, thanks for responding.

 

I should explain this further - I'm implementing Google Mini search on our site and would like to display the results within the site but not in an iframe as is the popular option.

 

I'm using simplexml to parse the xml and output it e.g.

$xml = simplexml_load_file($xmlfile);
//to get the total number of results
$total = $xml->RES->M;
return $total; 

 

I'm able to style the output as suggested however what I'm missing here is a way to apply the google xslt which contains all the spiffy 'extra' bits like 'related searches' etc.

 

So really my question should have been how would I apply an external xslt to the output? (My apologies, it's only after looking into it further today that I realise what I'm trying to do - total xml dunce)

 

Any guidance is appreciated.

 

C.

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.