Jump to content

SimpleXML


Mundo

Recommended Posts

I'm using an XML database called WURFL - it can be found here: http://wurfl.sourceforge.net/index.php

 

I want to use this to find out if a device can support either xHTML or WML and the resolution of the screen.

 

Can anybody help me with this?

 

I've got something like this but I'm a bit stuck...

 

<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
$xml = simplexml_load_file('wurfl.xml');
echo "Prefered Markup: " . $xml->$agent->preferred_markup;
echo "Maximum screen width: " . $xml->$agent->screenwidth . "px";
?>

 

Link to comment
https://forums.phpfreaks.com/topic/179858-simplexml/
Share on other sites

For example, an entry from the XML file is:

 

<device id="nokia_3330_ver1" user_agent="Nokia3330" fall_back="nokia_generic_series20" actual_device_root="true">
<group id="product_info">
  <capability name="model_name" value="3330" /> 
  </group>
<group id="storage">
  <capability name="max_deck_size" value="2800" /> 
  </group>
<group id="object_download">
  <capability name="wallpaper_gif" value="true" /> 
  </group>
<group id="display">
  <capability name="max_image_height" value="36" /> 
  </group>
<group id="markup">
  <capability name="xhtml_support_level" value="-1" /> 
  <capability name="preferred_markup" value="wml_1_1" /> 
  </group>
<group id="streaming">
  <capability name="streaming_real_media" value="none" /> 
  </group>
  </device>

 

How would I lookup "preferred_markup" depending on the HTTP_USER_AGENT with the SimpleXML features?

Link to comment
https://forums.phpfreaks.com/topic/179858-simplexml/#findComment-948972
Share on other sites

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.